Browse Source

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
dev-feat-component_preview
chris 2 months ago
parent
commit
2b50ed88d1
  1. 8
      src/component/Component.js
  2. 4
      src/component/FlexContainerComponent.js
  3. 7
      src/component/StyleAndScriptStoringComponent.js
  4. 20
      src/generators/generator.js

8
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);
}
}

4
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);
}
}

7
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);
}

20
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)
);
}
}

Loading…
Cancel
Save