@@ -25,19 +25,9 @@ function showMain() {
2525 removeClass ( document . getElementById ( MAIN_ID ) , "hidden" ) ;
2626}
2727
28- function elemIsInParent ( elem , parent ) {
29- while ( elem && elem !== document . body ) {
30- if ( elem === parent ) {
31- return true ;
32- }
33- elem = elem . parentElement ;
34- }
35- return false ;
36- }
37-
3828function blurHandler ( event , parentElem , hideCallback ) {
39- if ( ! elemIsInParent ( document . activeElement , parentElem ) &&
40- ! elemIsInParent ( event . relatedTarget , parentElem )
29+ if ( ! parentElem . contains ( document . activeElement ) &&
30+ ! parentElem . contains ( event . relatedTarget )
4131 ) {
4232 hideCallback ( ) ;
4333 }
@@ -1118,7 +1108,7 @@ function preLoadCss(cssUrl) {
11181108 if ( ev . pointerType !== "mouse" ) {
11191109 return ;
11201110 }
1121- if ( ! e . TOOLTIP_FORCE_VISIBLE && ! elemIsInParent ( ev . relatedTarget , e ) ) {
1111+ if ( ! e . TOOLTIP_FORCE_VISIBLE && ! e . contains ( ev . relatedTarget ) ) {
11221112 // See "Tooltip pointer leave gesture" below.
11231113 setTooltipHoverTimeout ( e , false ) ;
11241114 addClass ( wrapper , "fade-out" ) ;
@@ -1178,10 +1168,10 @@ function preLoadCss(cssUrl) {
11781168
11791169 function tooltipBlurHandler ( event ) {
11801170 if ( window . CURRENT_TOOLTIP_ELEMENT &&
1181- ! elemIsInParent ( document . activeElement , window . CURRENT_TOOLTIP_ELEMENT ) &&
1182- ! elemIsInParent ( event . relatedTarget , window . CURRENT_TOOLTIP_ELEMENT ) &&
1183- ! elemIsInParent ( document . activeElement , window . CURRENT_TOOLTIP_ELEMENT . TOOLTIP_BASE ) &&
1184- ! elemIsInParent ( event . relatedTarget , window . CURRENT_TOOLTIP_ELEMENT . TOOLTIP_BASE )
1171+ ! window . CURRENT_TOOLTIP_ELEMENT . contains ( document . activeElement ) &&
1172+ ! window . CURRENT_TOOLTIP_ELEMENT . contains ( event . relatedTarget ) &&
1173+ ! window . CURRENT_TOOLTIP_ELEMENT . TOOLTIP_BASE . contains ( document . activeElement ) &&
1174+ ! window . CURRENT_TOOLTIP_ELEMENT . TOOLTIP_BASE . contains ( event . relatedTarget )
11851175 ) {
11861176 // Work around a difference in the focus behaviour between Firefox, Chrome, and Safari.
11871177 // When I click the button on an already-opened tooltip popover, Safari
@@ -1248,8 +1238,8 @@ function preLoadCss(cssUrl) {
12481238 if ( ev . pointerType !== "mouse" ) {
12491239 return ;
12501240 }
1251- if ( ! e . TOOLTIP_FORCE_VISIBLE &&
1252- ! elemIsInParent ( ev . relatedTarget , window . CURRENT_TOOLTIP_ELEMENT ) ) {
1241+ if ( ! e . TOOLTIP_FORCE_VISIBLE && window . CURRENT_TOOLTIP_ELEMENT &&
1242+ ! window . CURRENT_TOOLTIP_ELEMENT . contains ( ev . relatedTarget ) ) {
12531243 // Tooltip pointer leave gesture:
12541244 //
12551245 // Designing a good hover microinteraction is a matter of guessing user
0 commit comments