UNPKG

taggedjs

Version:

tagged template reactive html

55 lines 2.1 kB
import { BasicTypes } from '../ValueTypes.enum.js'; import { isTagComponent } from '../../isInstance.js'; import { getNewGlobal } from './getNewGlobal.function.js'; import { handleStillTag } from './handleStillTag.function.js'; /** result is an indication to ignore further processing but that does not seem in use anymore */ export function tryUpdateToTag(contextItem, newValue, // newValue ownerSupport) { const isComp = isTagComponent(newValue); if (isComp) { if (contextItem.global === undefined) { getNewGlobal(contextItem); } contextItem.oldTagJsVar = contextItem.tagJsVar; contextItem.tagJsVar = newValue; prepareUpdateToComponent(newValue, contextItem, ownerSupport); return true; } // detect if previous value was a tag const global = contextItem.global; if (global) { contextItem.oldTagJsVar = contextItem.tagJsVar; contextItem.tagJsVar = newValue; // its html/dom based tag const support = contextItem.state.newest; if (support) { if (typeof (newValue) === BasicTypes.function) { return true; } handleStillTag(support, contextItem, newValue, ownerSupport); return true; } } if (contextItem.inputsHandler) { const props = ownerSupport.propsConfig; contextItem.inputsHandler(props); } ; newValue.processInit(newValue, contextItem, ownerSupport, contextItem.placeholder); contextItem.oldTagJsVar = contextItem.tagJsVar; contextItem.tagJsVar = newValue; return true; } function prepareUpdateToComponent(templater, contextItem, ownerSupport) { // When last value was not a component if (!contextItem.state.newest) { if (contextItem.inputsHandler) { const props = ownerSupport.propsConfig; contextItem.inputsHandler(props); } ; templater.processInit(templater, contextItem, ownerSupport, contextItem.placeholder); return; } } //# sourceMappingURL=tryUpdateToTag.function.js.map