From 2b50ed88d1b4de0a4160cd34e3c14dc84beda242 Mon Sep 17 00:00:00 2001 From: chris Date: Wed, 30 Apr 2025 15:26:58 +0200 Subject: [PATCH] FIX: generator used this (legacy from component) - changed method calls in generator from this (legacy from component) to component or similar. - removed modifier param from generate() method - reintroduced ExtStore initialization in Component ancestry since the extstore logic might be reevaluated all together the reintroduction is a quicker fix then to implement a dedicated solution that might be removed later anyway --- src/component/Component.js | 8 +------- src/component/FlexContainerComponent.js | 4 ++-- .../StyleAndScriptStoringComponent.js | 7 +++++++ src/generators/generator.js | 20 +++++++++++++------ 4 files changed, 24 insertions(+), 15 deletions(-) diff --git a/src/component/Component.js b/src/component/Component.js index fb8954b..f25ac2f 100644 --- a/src/component/Component.js +++ b/src/component/Component.js @@ -298,7 +298,7 @@ class Component extends StyleAndScriptStoringComponent { * @param {ExtStorage} * @returns {WebTrinity} the constructed HTMLElement of this Component. */ - generate(generator = singlepage, modifier = null, styleStore = null, functionStore = null) { + generate(generator = singlepage, styleStore = null, functionStore = null) { /** * In the case that this component is a chainChild created one. * The generation chain needs to be setup in the proper order @@ -317,12 +317,6 @@ class Component extends StyleAndScriptStoringComponent { .generate(generator, modifier, styleStore, functionStore); } - - if (modifier) { - this._modifier = modifier - .join(this._modifier); - } - return generator.generate(this, styleStore, functionStore); } } diff --git a/src/component/FlexContainerComponent.js b/src/component/FlexContainerComponent.js index 972ba2e..29fda2f 100644 --- a/src/component/FlexContainerComponent.js +++ b/src/component/FlexContainerComponent.js @@ -83,7 +83,7 @@ class FlexContainerComponent extends Component { * @inheritdoc * @extends Component.generate() */ - generate(generator = singlepage, modifier = null, styleStore = null, functionStore = null) { + generate(generator = singlepage, styleStore = null, functionStore = null) { if (this._children && this._children.length > 1) { if (this._distributeEvenglyAfterGenerate) { @@ -105,6 +105,6 @@ class FlexContainerComponent extends Component { } } - return super.generate(generator, modifier, styleStore, functionStore); + return super.generate(generator, styleStore, functionStore); } } diff --git a/src/component/StyleAndScriptStoringComponent.js b/src/component/StyleAndScriptStoringComponent.js index 297fa6a..1fec0fa 100644 --- a/src/component/StyleAndScriptStoringComponent.js +++ b/src/component/StyleAndScriptStoringComponent.js @@ -50,6 +50,13 @@ class StyleAndScriptStoringComponent extends ModifiableComponent { this._styles = []; this._isFunESDefault = true; this._functions = []; + + this._styleClassesExtStore = ExtStoreType.CENTRALIZED_DOC_HEAD + .setOverwriteBehaviour(OverwriteBehaviour.REPLACE); + this._stylesExtStore = ExtStoreType.INTERNALIZED_WITHIN + .setOverwriteBehaviour(OverwriteBehaviour.REPLACE); + this._functionsExtStore = ExtStoreType.CENTRALIZED_DOC_HEAD + .setOverwriteBehaviour(OverwriteBehaviour.REPLACE); } diff --git a/src/generators/generator.js b/src/generators/generator.js index fe133cc..5373cb9 100644 --- a/src/generators/generator.js +++ b/src/generators/generator.js @@ -62,7 +62,7 @@ class CompelGenerator { curExtStore = ssd._extStore.setupForGeneralStyling(); } - if (curExtStore.getStylingDistribution()(ssd, this._element, counter)) { + if (curExtStore.getStylingDistribution()(ssd, component._element, counter)) { forCollection.push(ssd); } } @@ -167,7 +167,8 @@ class CompelGenerator { /** * Generates and appends a child Component. - * @param {Component} component the child component to add it. + * @param {Component} parent component the child component to add it. + * @param {Component|WebTrinity|string} child * @returns {WebTrinity} */ appendChildComponent(parent, child) { @@ -182,10 +183,10 @@ class CompelGenerator { if (child instanceof HTMLElement) { console.log("No wenity set - htmlEl was given"); - childWT.compext = component; + childWT.compext = child; } - parent.append(childWT.compext); + parent._element.append(childWT.compext); return childWT; } @@ -208,7 +209,7 @@ class CompelGenerator { */ let wenities = []; - for (const child of component._children) { + for (let child of component._children) { child = child.generate(this, styleStore, functionStore); let wenity = this.appendChildComponent(component, child); @@ -231,6 +232,13 @@ class CompelGenerator { */ generate(component, styleStore = null, functionStore = null) { + if (!styleStore) { + styleStore = component._stylesExtStore; + } + if (!functionStore) { + functionStore = component._functionsExtStore; + } + /** * DEAL WITH COMPONENT MODIFICATION FIRST * @@ -276,7 +284,7 @@ class CompelGenerator { for (const child of childrenWenities) { if (child.scripts) { executeOnExtStoreTypeCollectedTriple( - (extstoretype) => transferCollectedFunctions(child.scripts, funcCollections, extstoretype) + (extstoretype) => this.transferCollectedFunctions(child.scripts, funcCollections, extstoretype) ); } }