@@ -574,24 +574,26 @@ bot.dom.isShown = function(elem, opt_ignoreOpacity) {
574
574
if ( bot . dom . getEffectiveStyle ( e , 'display' ) == 'none' ) {
575
575
return false ;
576
576
}
577
- var parent ;
578
- do {
579
- parent = bot . dom . getParentNodeInComposedDom ( e ) ;
580
- if ( parent instanceof ShadowRoot ) {
581
- if ( parent . host . shadowRoot != parent ) {
582
- // There is a younger shadow root, which will take precedence over
583
- // the shadow this element is in, thus this element won't be
584
- // displayed.
585
- return false ;
586
- } else {
587
- parent = parent . host ;
588
- }
589
- } else if ( parent && ( parent . nodeType == goog . dom . NodeType . DOCUMENT ||
590
- parent . nodeType == goog . dom . NodeType . DOCUMENT_FRAGMENT ) ) {
591
- parent = null ;
577
+
578
+ var parent = bot . dom . getParentNodeInComposedDom ( e ) ;
579
+
580
+ if ( parent instanceof ShadowRoot ) {
581
+ if ( parent . host . shadowRoot != parent ) {
582
+ // There is a younger shadow root, which will take precedence over
583
+ // the shadow this element is in, thus this element won't be
584
+ // displayed.
585
+ return false ;
586
+ } else {
587
+ parent = parent . host ;
592
588
}
593
- } while ( elem && elem . nodeType != goog . dom . NodeType . ELEMENT ) ;
594
- return ! parent || displayed ( parent ) ;
589
+ }
590
+
591
+ if ( parent && ( parent . nodeType == goog . dom . NodeType . DOCUMENT ||
592
+ parent . nodeType == goog . dom . NodeType . DOCUMENT_FRAGMENT ) ) {
593
+ return true ;
594
+ }
595
+
596
+ return parent && displayed ( parent ) ;
595
597
} ;
596
598
} else {
597
599
// Any element with a display style equal to 'none' or that has an ancestor
@@ -601,7 +603,7 @@ bot.dom.isShown = function(elem, opt_ignoreOpacity) {
601
603
return false ;
602
604
}
603
605
var parent = bot . dom . getParentElement ( e ) ;
604
- return ! parent || displayed ( parent ) ;
606
+ return parent && displayed ( parent ) ;
605
607
} ;
606
608
}
607
609
return bot . dom . isShown_ ( elem , ! ! opt_ignoreOpacity , displayed ) ;
@@ -1260,12 +1262,19 @@ bot.dom.getOpacityNonIE_ = function(elem) {
1260
1262
*/
1261
1263
bot . dom . getParentNodeInComposedDom = function ( node ) {
1262
1264
var /**@type {Node }*/ parent = node . parentNode ;
1265
+ // Shadow DOM V0 (deprecated)
1263
1266
if ( node . getDestinationInsertionPoints ) {
1264
1267
var destinations = node . getDestinationInsertionPoints ( ) ;
1265
1268
if ( destinations . length > 0 ) {
1266
1269
parent = destinations [ destinations . length - 1 ] ;
1267
1270
}
1268
1271
}
1272
+ // Shadow DOM v1
1273
+ if ( parent . shadowRoot && node . assignedSlot !== undefined ) {
1274
+ // Can be null on purpose, meaning it has no parent as
1275
+ // it hasn't yet been slotted
1276
+ parent = node . assignedSlot ;
1277
+ }
1269
1278
return parent ;
1270
1279
} ;
1271
1280
@@ -1359,8 +1368,10 @@ bot.dom.isNodeDistributedIntoShadowDom = function(node) {
1359
1368
elemOrText = /** @type {!Text } */ ( node ) ;
1360
1369
}
1361
1370
return elemOrText != null &&
1362
- elemOrText . getDestinationInsertionPoints &&
1363
- elemOrText . getDestinationInsertionPoints ( ) . length > 0 ;
1371
+ ( elemOrText . assignedSlot != null ||
1372
+ ( elemOrText . getDestinationInsertionPoints &&
1373
+ elemOrText . getDestinationInsertionPoints ( ) . length > 0 )
1374
+ ) ;
1364
1375
} ;
1365
1376
1366
1377
0 commit comments