From 32cb4ac63af92ea6e56352b911a52060af672b6b Mon Sep 17 00:00:00 2001 From: Florin Raducan Date: Mon, 22 Apr 2024 23:49:35 +0300 Subject: [PATCH] #461424 #461425 - Code cleanup --- blocks/accordion/accordion.js | 29 +++++++++++++---------------- blocks/button/button.js | 12 ++++++++++-- blocks/column/column.js | 3 +-- blocks/columns/columns.js | 1 - scripts/component-loader.js | 2 +- 5 files changed, 25 insertions(+), 22 deletions(-) diff --git a/blocks/accordion/accordion.js b/blocks/accordion/accordion.js index db1922ba..1705e08a 100644 --- a/blocks/accordion/accordion.js +++ b/blocks/accordion/accordion.js @@ -3,22 +3,19 @@ import ComponentBase from '../../scripts/component-base.js'; export default class Accordion extends ComponentBase { dependencies = ['icon']; - // extendNestedConfig() { - // return [ - // ...super.extendNestedConfig(), - // { - // button: { - // componentName: 'button', - // // active: false, - // loaderConfig: { - // targetsSelectorsPrefix: ':not(.accordion-control) >', - // }, - // }, - // }, - // ]; - // } - - // nestedComponentsConfig = {}; + extendNestedConfig() { + return [ + ...super.extendNestedConfig(), + { + button: { + componentName: 'button', + loaderConfig: { + targetsSelectorsPrefix: ':scope > :is(:nth-child(even)) >', + }, + }, + }, + ]; + } ready() { this.setAttribute('role', 'navigation'); diff --git a/blocks/button/button.js b/blocks/button/button.js index 7eb4d9b2..ca0cc23f 100644 --- a/blocks/button/button.js +++ b/blocks/button/button.js @@ -6,8 +6,16 @@ export default class Button extends ComponentBase { targetsSelectors: ':is(p,div):has(> a:only-child)', selectorTest: (el) => el.childNodes.length === 1, }; - - nestedComponentsConfig = {}; + + nestedComponentsConfig = { + columns: { + componentName: 'columns', + active: false, + loaderConfig: { + targetsAsContainers: false, + }, + }, + }; extendConfig() { return [ diff --git a/blocks/column/column.js b/blocks/column/column.js index f3ea5a0d..18fc90ed 100644 --- a/blocks/column/column.js +++ b/blocks/column/column.js @@ -1,7 +1,6 @@ import ComponentBase from '../../scripts/component-base.js'; -// ! Solution 1 to remove mixins -export default class ColumnN extends ComponentBase { +export default class Column extends ComponentBase { static observedAttributes = ['position', 'size', 'justify']; connected() { diff --git a/blocks/columns/columns.js b/blocks/columns/columns.js index 3d77e77b..b99948a4 100644 --- a/blocks/columns/columns.js +++ b/blocks/columns/columns.js @@ -1,6 +1,5 @@ import { collectAttributes } from '../../scripts/libs.js'; -// ! Solution 2 to remove mixins export default class Columns { static observedAttributes = ['position', 'size', 'justify']; diff --git a/scripts/component-loader.js b/scripts/component-loader.js index 95455d7e..3db8d095 100644 --- a/scripts/component-loader.js +++ b/scripts/component-loader.js @@ -134,7 +134,7 @@ export default class ComponentLoader { ); Object.keys(currentAttributes).forEach((key) => { - componentElem.setAttribute(key, currentAttributes[key]); + componentElem.setAttribute(key, currentAttributes[key].trim()); }); componentElem.nestedComponentsConfig = deepMerge(