Skip to content

Commit 6df7fe1

Browse files
committed
fix(jqLite): do not break if Node is not available
Fixes angular#13442
1 parent 8f0b482 commit 6df7fe1

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/jqLite.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,10 @@ function jqLiteParseHTML(html, context) {
256256

257257

258258
// IE9-11 has no method "contains" in SVG element and in Node.prototype. Bug #10259.
259-
var jqLiteContains = Node.prototype.contains || function(arg) {
259+
var jqLiteContains = function(parentNode, childNode) {
260260
// jshint bitwise: false
261-
return !!(this.compareDocumentPosition(arg) & 16);
261+
return parentNode.contains ? parentNode.contains(childNode)
262+
: !!(parentNode.compareDocumentPosition(childNode) & 16);
262263
// jshint bitwise: true
263264
};
264265

@@ -824,7 +825,7 @@ function specialMouseHandlerWrapper(target, event, handler) {
824825
var related = event.relatedTarget;
825826
// For mousenter/leave call the handler if related is outside the target.
826827
// NB: No relatedTarget if the mouse left/entered the browser window
827-
if (!related || (related !== target && !jqLiteContains.call(target, related))) {
828+
if (!related || (related !== target && !jqLiteContains(target, related))) {
828829
handler.call(target, event);
829830
}
830831
}

0 commit comments

Comments
 (0)