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.
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 ischeckTwo
.Thanks for your time!