Browse Source

DRAFT,IMPL,DOC: changed loop approaches

dev-feat-component_preview
chris 2 months ago
parent
commit
e539ace5a0
  1. 4
      src/component/Component.js
  2. 50
      src/generators/generator.js

4
src/component/Component.js

@ -398,14 +398,14 @@ class Component extends StyleAndScriptStoringComponent {
* Processes alls stored additions. * Processes alls stored additions.
* Returns the constructed HTMLElement of this Component. * Returns the constructed HTMLElement of this Component.
* *
* * @param {CompelGenerator} generator
* @param {Modifier | undefined} [modifier=null] * @param {Modifier | undefined} [modifier=null]
* @param {ExtStorage | undefined} [styleStore=null] * @param {ExtStorage | undefined} [styleStore=null]
* @param {ExtStorage | undefined} [functionStore=null] * @param {ExtStorage | undefined} [functionStore=null]
* @param {ExtStorage} * @param {ExtStorage}
* @returns {WebTrinity} the constructed HTMLElement of this Component. * @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) { if (this._parentComponent) {
let parent = this._parentComponent; let parent = this._parentComponent;
this._parentComponent = null; this._parentComponent = null;

50
src/generators/generator.js

@ -1,7 +1,17 @@
/** /**
* This file is part of the jps-like-websites lib * This module defines the Component generator.
* URL: https://git.labos.goip.de/chris/jpc-like-websites * It externalizes all decision making about script or style storage from the component.
* @copyright by its creator Christian Martin * 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 { class CompelGenerator {
@ -15,7 +25,7 @@ class CompelGenerator {
} }
/** /**
* * @param {Component} component
* @param {ExtStorage} extStore * @param {ExtStorage} extStore
* @returns {Array<SStoreDefinition>} * @returns {Array<SStoreDefinition>}
*/ */
@ -29,7 +39,7 @@ class CompelGenerator {
let forCollection = []; let forCollection = [];
let counter = 0; 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 */ /* Make sure that the type is unified for later processing */
if (ssd._definition instanceof Modifier) { if (ssd._definition instanceof Modifier) {
ssd._definition = ssd._definition._modifications; ssd._definition = ssd._definition._modifications;
@ -119,7 +129,7 @@ class CompelGenerator {
/** /**
* *
* @param {Comment} component * @param {Component} component
* @returns {Array<WebTrinity>} * @returns {Array<WebTrinity>}
*/ */
resolveChildren(component) { resolveChildren(component) {
@ -128,19 +138,11 @@ class CompelGenerator {
*/ */
let wenities = []; let wenities = [];
for (let i = 0; i < component._children.length; i++) { for (const child of component._children) {
/**
* @type {Component}
*/
let child = component._children[i];
if (child instanceof ChainableModifier) { if (child instanceof ChainableModifier) {
child = child.toComponent(); child = child.toComponent();
} }
if (Page._useCssCalc) {
child._modifier._updateDimensionsBy(component._modifier._paddingValues);
}
child = child.generate(); child = child.generate();
let wenity = this.appendChildComponent(component, child); let wenity = this.appendChildComponent(component, child);
@ -168,6 +170,10 @@ class CompelGenerator {
} }
/** /**
* *
* @param {Component} component * @param {Component} component
@ -176,6 +182,17 @@ class CompelGenerator {
* @returns {WebTrinity} * @returns {WebTrinity}
*/ */
generate(component, styleStore = null, functionStore = null) { 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 */ /* DEAL WITH COMPONENT MODIFICATION FIRST */
// @todo pay attention to the "overwrite" behaviour - the local modifier styles are the "closest" // @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); let funcCollections = this.processFunctions(functionStore);
for (let i = 0; i < childrenWenities.length; i++) { for (const child of childrenWenities) {
const child = childrenWenities[i];
if (child.js) { if (child.js) {
executeOnExtStoreTypeCollectedTriple( executeOnExtStoreTypeCollectedTriple(
(extstoretype) => transferCollectedFunctions(child.js, funcCollections, extstoretype) (extstoretype) => transferCollectedFunctions(child.js, funcCollections, extstoretype)

Loading…
Cancel
Save