Adyen / adyen-cse-web

[DEPRECATED] Client-side encryption on JavaScript
MIT License
15 stars 39 forks source link

fix broken check in case of element not having a ownerDocument property #58

Closed thomasdobber closed 7 years ago

ArnoudAdyen commented 7 years ago

Hi Thomas,

After running some checks, also the suggested implementation is not giving the right results.

While looking for better implementations the safest seems to be:

if (typeof element !== 'object' || element === null || typeof element.ownerDocument !== 'object' || element.ownerDocument === null )

Slightly verbose, but seems to be closest to what we need. I wonder if we could use element.ownerDocument instanceof HTMLDocument, but I'm not sure that works in non browser context.

For test results, see https://jsfiddle.net/mbsqmedu/1/ against various test scenarios. The one that will go in the next version will be version checkOne and the suggested implementation is checkTwo.

Thanks for your time!