fix: changed selectors for invokers and content to only select slotted elements that are direct descendants. This is to prevent that slotted elements in accordion content and invokers are also selected and the amount of invokers and content is incorrect

This commit is contained in:
Danny Moerkerke 2023-03-09 15:33:24 +01:00
parent ecea06cb6e
commit 3f1c83a180
2 changed files with 7 additions and 2 deletions

View file

@ -0,0 +1,5 @@
---
'@lion/ui': patch
---
lion-accordion: changed selectors for invokers and content to only select slotted elements that are direct descendants. This is to prevent that slotted elements in accordion content and invokers are also selected and the amount of invokers and content is incorrect

View file

@ -171,12 +171,12 @@ export class LionAccordion extends LitElement {
const invokers = /** @type {HTMLElement[]} */ ([ const invokers = /** @type {HTMLElement[]} */ ([
...Array.from(existingInvokers), ...Array.from(existingInvokers),
...Array.from(this.querySelectorAll('[slot="invoker"]')), ...Array.from(this.querySelectorAll(':scope > [slot="invoker"]')),
]); ]);
const contents = /** @type {HTMLElement[]} */ ([ const contents = /** @type {HTMLElement[]} */ ([
...Array.from(existingContent), ...Array.from(existingContent),
...Array.from(this.querySelectorAll('[slot="content"]')), ...Array.from(this.querySelectorAll(':scope > [slot="content"]')),
]); ]);
if (invokers.length !== contents.length) { if (invokers.length !== contents.length) {