@@ -156,6 +156,30 @@ wrapMap.optgroup = wrapMap.option;
156
156
wrapMap . tbody = wrapMap . tfoot = wrapMap . colgroup = wrapMap . caption = wrapMap . thead ;
157
157
wrapMap . th = wrapMap . td ;
158
158
159
+
160
+ var elementContains = document . head . contains ||
161
+ document . head . compareDocumentPosition
162
+ ? function ( a , b ) {
163
+ // jshint bitwise: false
164
+ var adown = a . nodeType === 9 ? a . documentElement : a ,
165
+ bup = b && b . parentNode ;
166
+ return a === bup || ! ! ( bup && bup . nodeType === 1 && (
167
+ adown . contains ?
168
+ adown . contains ( bup ) :
169
+ a . compareDocumentPosition && a . compareDocumentPosition ( bup ) & 16
170
+ ) ) ;
171
+ }
172
+ : function ( a , b ) {
173
+ if ( b ) {
174
+ while ( ( b = b . parentNode ) ) {
175
+ if ( b === a ) {
176
+ return true ;
177
+ }
178
+ }
179
+ }
180
+ return false ;
181
+ } ;
182
+
159
183
function jqLiteIsTextNode ( html ) {
160
184
return ! HTML_REGEXP . test ( html ) ;
161
185
}
@@ -782,28 +806,6 @@ forEach({
782
806
783
807
if ( ! eventFns ) {
784
808
if ( type == 'mouseenter' || type == 'mouseleave' ) {
785
- var contains = document . body . contains || document . body . compareDocumentPosition ?
786
- function ( a , b ) {
787
- // jshint bitwise: false
788
- var adown = a . nodeType === 9 ? a . documentElement : a ,
789
- bup = b && b . parentNode ;
790
- return a === bup || ! ! ( bup && bup . nodeType === 1 && (
791
- adown . contains ?
792
- adown . contains ( bup ) :
793
- a . compareDocumentPosition && a . compareDocumentPosition ( bup ) & 16
794
- ) ) ;
795
- } :
796
- function ( a , b ) {
797
- if ( b ) {
798
- while ( ( b = b . parentNode ) ) {
799
- if ( b === a ) {
800
- return true ;
801
- }
802
- }
803
- }
804
- return false ;
805
- } ;
806
-
807
809
events [ type ] = [ ] ;
808
810
809
811
// Refer to jQuery's implementation of mouseenter & mouseleave
@@ -815,7 +817,7 @@ forEach({
815
817
var target = this , related = event . relatedTarget ;
816
818
// For mousenter/leave call the handler if related is outside the target.
817
819
// NB: No relatedTarget if the mouse left/entered the browser window
818
- if ( ! related || ( related !== target && ! contains ( target , related ) ) ) {
820
+ if ( ! related || ( related !== target && ! elementContains ( target , related ) ) ) {
819
821
handle ( event , type ) ;
820
822
}
821
823
} ) ;
0 commit comments