diff --git a/index.js b/index.js index d01f0d9..58cfd63 100644 --- a/index.js +++ b/index.js @@ -17,5 +17,5 @@ module.exports = contains; */ function contains (node, other) { - return node === other || !!(node.compareDocumentPosition(other) & 16); + return other && (node === other || !!(node.compareDocumentPosition(other) & 16) ); }