diff options
Diffstat (limited to 'src/selector/contains.js')
-rw-r--r-- | src/selector/contains.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/selector/contains.js b/src/selector/contains.js new file mode 100644 index 000000000..0d6273c28 --- /dev/null +++ b/src/selector/contains.js @@ -0,0 +1,22 @@ +define( [ + "../core" +], function( jQuery ) { + +"use strict"; + +// Note: an element does not contain itself +jQuery.contains = function( a, b ) { + var adown = a.nodeType === 9 ? a.documentElement : a, + bup = b && b.parentNode; + + return a === bup || !!( bup && bup.nodeType === 1 && ( + + // Support: IE 9 - 11+ + // IE doesn't have `contains` on SVG. + adown.contains ? + adown.contains( bup ) : + a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16 + ) ); +}; + +} ); |