Skip to content

Commit 011338d

Browse files
43081jshs96c
authored andcommitted
return early when retrieving DOM parents
1 parent 4557baf commit 011338d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

javascript/atoms/dom.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,19 +1251,22 @@ bot.dom.getOpacityNonIE_ = function(elem) {
12511251
*/
12521252
bot.dom.getParentNodeInComposedDom = function(node) {
12531253
var /**@type {Node}*/ parent = node.parentNode;
1254+
12541255
// Shadow DOM v1
12551256
if (parent.shadowRoot && node.assignedSlot !== undefined) {
12561257
// Can be null on purpose, meaning it has no parent as
12571258
// it hasn't yet been slotted
1258-
parent = node.assignedSlot ? node.assignedSlot.parentNode : null;
1259+
return node.assignedSlot ? node.assignedSlot.parentNode : null;
12591260
}
1261+
12601262
// Shadow DOM V0 (deprecated)
12611263
if (node.getDestinationInsertionPoints) {
12621264
var destinations = node.getDestinationInsertionPoints();
12631265
if (destinations.length > 0) {
1264-
parent = destinations[destinations.length - 1];
1266+
return destinations[destinations.length - 1];
12651267
}
12661268
}
1269+
12671270
return parent;
12681271
};
12691272

0 commit comments

Comments
 (0)