melody-idom
Advanced tools
Comparing version 1.2.0-commit.33988325 to 1.2.0-commit.05c42290
@@ -64,2 +64,19 @@ /** | ||
/** | ||
* Function that checks whether some element is contained inside a node. This function | ||
* has a fallback implementation for cases where Node.prototype.contains is | ||
* not implemented (e.g. IE11 for SVGElements). | ||
* @param {!Node} node The node that should be parent of elm. | ||
* @param {?Element} elm The element that should be child of elm. | ||
* @return {Boolean} whether or not elm is contained within node. | ||
*/ | ||
var nodeContainsElement = function (node, elm) { | ||
if (node.contains) { | ||
return node.contains(elm); | ||
} | ||
while (elm && elm !== node) { | ||
elm = elm.parentNode; | ||
} | ||
return elm === node; | ||
}; | ||
/** | ||
* Gets the path of nodes that contain the focused node in the same document as | ||
@@ -73,3 +90,3 @@ * a reference node, up until the root. | ||
var activeElement = getActiveElement(node); | ||
if (!activeElement || !node.contains(activeElement)) { | ||
if (!activeElement || !nodeContainsElement(node, activeElement)) { | ||
return []; | ||
@@ -76,0 +93,0 @@ } |
@@ -538,2 +538,19 @@ import _debounce from 'lodash/debounce'; | ||
/** | ||
* Function that checks whether some element is contained inside a node. This function | ||
* has a fallback implementation for cases where Node.prototype.contains is | ||
* not implemented (e.g. IE11 for SVGElements). | ||
* @param {!Node} node The node that should be parent of elm. | ||
* @param {?Element} elm The element that should be child of elm. | ||
* @return {Boolean} whether or not elm is contained within node. | ||
*/ | ||
var nodeContainsElement = function nodeContainsElement(node, elm) { | ||
if (node.contains) { | ||
return node.contains(elm); | ||
} | ||
while (elm && elm !== node) { | ||
elm = elm.parentNode; | ||
} | ||
return elm === node; | ||
}; | ||
/** | ||
* Gets the path of nodes that contain the focused node in the same document as | ||
@@ -547,3 +564,3 @@ * a reference node, up until the root. | ||
var activeElement = getActiveElement(node); | ||
if (!activeElement || !node.contains(activeElement)) { | ||
if (!activeElement || !nodeContainsElement(node, activeElement)) { | ||
return []; | ||
@@ -550,0 +567,0 @@ } |
@@ -544,2 +544,19 @@ 'use strict'; | ||
/** | ||
* Function that checks whether some element is contained inside a node. This function | ||
* has a fallback implementation for cases where Node.prototype.contains is | ||
* not implemented (e.g. IE11 for SVGElements). | ||
* @param {!Node} node The node that should be parent of elm. | ||
* @param {?Element} elm The element that should be child of elm. | ||
* @return {Boolean} whether or not elm is contained within node. | ||
*/ | ||
var nodeContainsElement = function nodeContainsElement(node, elm) { | ||
if (node.contains) { | ||
return node.contains(elm); | ||
} | ||
while (elm && elm !== node) { | ||
elm = elm.parentNode; | ||
} | ||
return elm === node; | ||
}; | ||
/** | ||
* Gets the path of nodes that contain the focused node in the same document as | ||
@@ -553,3 +570,3 @@ * a reference node, up until the root. | ||
var activeElement = getActiveElement(node); | ||
if (!activeElement || !node.contains(activeElement)) { | ||
if (!activeElement || !nodeContainsElement(node, activeElement)) { | ||
return []; | ||
@@ -556,0 +573,0 @@ } |
{ | ||
"name": "melody-idom", | ||
"version": "1.2.0-commit.33988325", | ||
"version": "1.2.0-commit.05c42290", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
@@ -73,2 +73,22 @@ /** | ||
/** | ||
* Function that checks whether some element is contained inside a node. This function | ||
* has a fallback implementation for cases where Node.prototype.contains is | ||
* not implemented (e.g. IE11 for SVGElements). | ||
* @param {!Node} node The node that should be parent of elm. | ||
* @param {?Element} elm The element that should be child of elm. | ||
* @return {Boolean} whether or not elm is contained within node. | ||
*/ | ||
const nodeContainsElement = function(node, elm) { | ||
if (node.contains) { | ||
return node.contains(elm); | ||
} | ||
while (elm && elm !== node) { | ||
elm = elm.parentNode; | ||
} | ||
return elm === node; | ||
}; | ||
/** | ||
* Gets the path of nodes that contain the focused node in the same document as | ||
@@ -83,3 +103,3 @@ * a reference node, up until the root. | ||
if (!activeElement || !node.contains(activeElement)) { | ||
if (!activeElement || !nodeContainsElement(node, activeElement)) { | ||
return []; | ||
@@ -86,0 +106,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
274969
8222