From 3f1c83a180bf9038502fd6b651da527a4da7c5a1 Mon Sep 17 00:00:00 2001 From: Danny Moerkerke Date: Thu, 9 Mar 2023 15:33:24 +0100 Subject: [PATCH] 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 --- .changeset/silly-beds-teach.md | 5 +++++ packages/ui/components/accordion/src/LionAccordion.js | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .changeset/silly-beds-teach.md diff --git a/.changeset/silly-beds-teach.md b/.changeset/silly-beds-teach.md new file mode 100644 index 000000000..26a15fcd1 --- /dev/null +++ b/.changeset/silly-beds-teach.md @@ -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 diff --git a/packages/ui/components/accordion/src/LionAccordion.js b/packages/ui/components/accordion/src/LionAccordion.js index 079f12aff..e3ecffc8c 100644 --- a/packages/ui/components/accordion/src/LionAccordion.js +++ b/packages/ui/components/accordion/src/LionAccordion.js @@ -171,12 +171,12 @@ export class LionAccordion extends LitElement { const invokers = /** @type {HTMLElement[]} */ ([ ...Array.from(existingInvokers), - ...Array.from(this.querySelectorAll('[slot="invoker"]')), + ...Array.from(this.querySelectorAll(':scope > [slot="invoker"]')), ]); const contents = /** @type {HTMLElement[]} */ ([ ...Array.from(existingContent), - ...Array.from(this.querySelectorAll('[slot="content"]')), + ...Array.from(this.querySelectorAll(':scope > [slot="content"]')), ]); if (invokers.length !== contents.length) {