Browse Source

MINOR,FEAT: created convenience functions in builder for dev

master
chris 3 days ago
parent
commit
9557335694
  1. 58
      src/builder.js

58
src/builder.js

@ -38,6 +38,64 @@ const builder = {
} }
}, },
/**
* Pure convenience, mostly to enable jdocs for builder.extensions
* @param {*} unrecognizedComponent
* @returns {Component}
*/
asComponent(unrecognizedComponent) {
if (unrecognizedComponent instanceof Component) {
console.log("Recognized as Component");
return unrecognizedComponent;
} else if (unrecognizedComponent instanceof Modifier) {
return unrecognizedComponent.toComponent()
}
console.log("NOT Recognized");
return unrecognizedComponent;
},
/**
* Pure convenience, mostly to enable jdocs for builder.extensions
* in this case if there is an actual difference as the element being
* a FlexContainerComponent
* @param {*} unrecognizedComponent
* @returns {FlexContainerComponent}
*/
asFlexContainerComponent(unrecognizedComponent) {
if (unrecognizedComponent instanceof FlexContainerComponent) {
console.log("Recognized as FlexContainerComponent");
return unrecognizedComponent;
} else if (unrecognizedComponent instanceof Modifier) {
return unrecognizedComponent.toComponent()
}
console.log("NOT Recognized");
return unrecognizedComponent;
},
/**
* Pure convenience, mostly to enable jdocs for builder.extensions
* in this case if there is an actual difference as the element being
* an InputComponent
* @param {*} unrecognizedComponent
* @returns {InputComponent}
*/
asInputComponent(unrecognizedComponent) {
if (unrecognizedComponent instanceof InputComponent) {
console.log("Recognized as InputComponent");
return unrecognizedComponent;
} else if (unrecognizedComponent instanceof Modifier) {
return unrecognizedComponent.toComponent()
}
console.log("NOT Recognized");
return unrecognizedComponent;
},
/** /**
* *
* @param {string} htmlText * @param {string} htmlText

Loading…
Cancel
Save