aboutsummaryrefslogtreecommitdiffstats
path: root/src/core.js
diff options
context:
space:
mode:
authorMichał Gołębiowski-Owczarek <m.goleb@gmail.com>2022-12-12 22:27:59 +0100
committerGitHub <noreply@github.com>2022-12-12 22:27:59 +0100
commit024d87195ac46690023e2b0b308d4406a8a5a27e (patch)
tree7238b95beb38397175388af04006c08d1a1edf78 /src/core.js
parentc909d6b1ff444e68618b6da13d9c21714f681925 (diff)
downloadjquery-024d87195ac46690023e2b0b308d4406a8a5a27e.tar.gz
jquery-024d87195ac46690023e2b0b308d4406a8a5a27e.zip
Core:Selector: Move jQuery.contains from the selector to the core module
The `jQuery.contains` method is quite simple in jQuery 4+. On the other side, it's a dependency of the core `isAttached` util which is not ideal; moving it from the `selector` the `core` module resolves the issue. Closes gh-5167
Diffstat (limited to 'src/core.js')
-rw-r--r--src/core.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/core.js b/src/core.js
index 4f5731ae1..16cd9a7c7 100644
--- a/src/core.js
+++ b/src/core.js
@@ -314,6 +314,20 @@ jQuery.extend( {
return !rhtmlSuffix.test( namespace || docElem && docElem.nodeName || "HTML" );
},
+ // Note: an element does not contain itself
+ contains: function( a, b ) {
+ var bup = b && b.parentNode;
+
+ return a === bup || !!( bup && bup.nodeType === 1 && (
+
+ // Support: IE 9 - 11+
+ // IE doesn't have `contains` on SVG.
+ a.contains ?
+ a.contains( bup ) :
+ a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
+ ) );
+ },
+
merge: function( first, second ) {
var len = +second.length,
j = 0,