Closed depeele closed 6 years ago
This approach is going to cause issues when working with nested components. For example:
<x-buttons id="buttons-1">
<x-button id="button-1">
<x-popover>
<x-button id="button-2"></x-button>
</x-popover>
</x-button>
</x-buttons>
#button-2.ownerButtons
should be null
, not #buttons-1
.
I have committed a fix which checks whether this.parentElement.parentElement
exists before performing further checks.
Use
closest()
instead of ad-hoc parent checks to identify anyx-buttons
container.This avoids errors when a one or more
x-button
elements are contained within anx-box
at the top-level of a component. In this case, thex-box
is at the top of theshadowRoot
and technically has no parent element. This would cause the ad-hoc check to fail atthis.parentElement.parentElement.localName
sincethis.parentElement.parentElement
isnull
.