aboutsummaryrefslogtreecommitdiffstats
path: root/src/selector/contains.js
blob: 0d6273c286b9013d05639c2ef1bc351c6243ee94 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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
	) );
};

} );