diff --git a/src/component/Component.js b/src/component/Component.js index 773d35d..aa9b3b4 100644 --- a/src/component/Component.js +++ b/src/component/Component.js @@ -398,14 +398,14 @@ class Component extends StyleAndScriptStoringComponent { * Processes alls stored additions. * Returns the constructed HTMLElement of this Component. * - * + * @param {CompelGenerator} generator * @param {Modifier | undefined} [modifier=null] * @param {ExtStorage | undefined} [styleStore=null] * @param {ExtStorage | undefined} [functionStore=null] * @param {ExtStorage} * @returns {WebTrinity} the constructed HTMLElement of this Component. */ - generate(modifier = null, generator, styleStore = null, functionStore = null) { + generate(generator, modifier = null, styleStore = null, functionStore = null) { if (this._parentComponent) { let parent = this._parentComponent; this._parentComponent = null; diff --git a/src/generators/generator.js b/src/generators/generator.js index 62411e6..4f71e3b 100644 --- a/src/generators/generator.js +++ b/src/generators/generator.js @@ -1,7 +1,17 @@ /** - * This file is part of the jps-like-websites lib - * URL: https://git.labos.goip.de/chris/jpc-like-websites - * @copyright by its creator Christian Martin + * This module defines the Component generator. + * It externalizes all decision making about script or style storage from the component. + * The component stores the generator (if set, if not =default or passed down from parent component). + * The CompelGenerator class enables the setup/definition of storage, generation and distribution. + * + * Further if other frameworks are targeted: + * if the components should be generated in a manner + * that they fullfill the setup/look of other framework-components. + * Only the generator has to be modified, implemented, extended ... + * not the component, modifier or any other of the classes. + * + * Therefore the usages of CompelGenerator-feature-logic resets all style and script storages to local. + * Only towards the end (when "generate()" is called) any of that will be resolved. */ class CompelGenerator { @@ -15,7 +25,7 @@ class CompelGenerator { } /** - * + * @param {Component} component * @param {ExtStorage} extStore * @returns {Array} */ @@ -29,7 +39,7 @@ class CompelGenerator { let forCollection = []; let counter = 0; - for (const ssd of this._styles) { + for (const ssd of component._styles) { /* Make sure that the type is unified for later processing */ if (ssd._definition instanceof Modifier) { ssd._definition = ssd._definition._modifications; @@ -119,7 +129,7 @@ class CompelGenerator { /** * - * @param {Comment} component + * @param {Component} component * @returns {Array} */ resolveChildren(component) { @@ -128,19 +138,11 @@ class CompelGenerator { */ let wenities = []; - for (let i = 0; i < component._children.length; i++) { - /** - * @type {Component} - */ - let child = component._children[i]; - + for (const child of component._children) { if (child instanceof ChainableModifier) { child = child.toComponent(); } - if (Page._useCssCalc) { - child._modifier._updateDimensionsBy(component._modifier._paddingValues); - } child = child.generate(); let wenity = this.appendChildComponent(component, child); @@ -168,6 +170,10 @@ class CompelGenerator { } + + + + /** * * @param {Component} component @@ -176,6 +182,17 @@ class CompelGenerator { * @returns {WebTrinity} */ generate(component, styleStore = null, functionStore = null) { + /** + * check if component is chained child, + * if so resolve chaining first. + */ + if (component._parentComponent) { + let parent = component._parentComponent; + component._parentComponent = null; + return parent.childContext(component) + .generate(this) + } + /* DEAL WITH COMPONENT MODIFICATION FIRST */ // @todo pay attention to the "overwrite" behaviour - the local modifier styles are the "closest" @@ -204,8 +221,7 @@ class CompelGenerator { */ let funcCollections = this.processFunctions(functionStore); - for (let i = 0; i < childrenWenities.length; i++) { - const child = childrenWenities[i]; + for (const child of childrenWenities) { if (child.js) { executeOnExtStoreTypeCollectedTriple( (extstoretype) => transferCollectedFunctions(child.js, funcCollections, extstoretype)