UNPKG

taggedjs

Version:

tagged template reactive html

74 lines 3.26 kB
import { ValueTypes } from '../ValueTypes.enum.js'; import { getCastedProps } from '../getTagWrap.function.js'; import { createSupport } from '../createSupport.function.js'; import { firstTagRender } from '../../render/renderTagOnly.function.js'; import { castProps } from '../props/alterProp.function.js'; import { convertTagToElementManaged } from './convertTagToElementManaged.function.js'; import { removeContextInCycle, setContextInCycle } from '../cycles/setContextInCycle.function.js'; function createSupportWithProps(templater, subject, ownerSupport) { const newSupport = createSupport(templater, subject, ownerSupport, ownerSupport?.appSupport); const newPropsConfig = newSupport.propsConfig; if (newPropsConfig) { const castedProps = templater.tagJsType !== ValueTypes.tagComponent ? [] : getCastedProps(templater, newSupport); newPropsConfig.castProps = castedProps; } const support = firstTagRender(newSupport, subject.state.newest, // existing tag subject); return support; } export function processReplacementComponent(templater, context, ownerSupport) { const support = createSupportWithProps(templater, context, ownerSupport); const tag = support.templater.tag; if (!tag) { return support; } return convertTagToElementManaged(support, support.ownerSupport, context); } export function makeRealUpdate(newContext, value, context, convertValue, support) { // We need to deprecate this completely (castProps) const castedProps = castProps(value.props, support, // ownerSupport, 0); const newValue = newContext.value; newValue.props = castedProps; const propsConfig = support.propsConfig; if (propsConfig) { propsConfig.castProps = castedProps; } // TODO this outer condition may not be needed at all if (value?.tagJsType === 'tagComponent') { newContext.inputsHandler = context.inputsHandler; newContext.updatesHandler = context.updatesHandler; context.value = value; if (context.inputsHandler) { setContextInCycle(context); const inputsHandler = context.inputsHandler; inputsHandler(castedProps); // .inputs() removeContextInCycle(); } if (context.updatesHandler) { setContextInCycle(context); const updatesHandler = context.updatesHandler; updatesHandler(castedProps); // .updates() removeContextInCycle(); } } newContext.tagJsVar.processUpdate(convertValue, newContext, support, []); newContext.value = convertValue; // paint() } export function afterDestroy(context, _ownerSupport) { delete context.returnValue; delete context.global // = {} as any; ; context.contexts = []; ; context.htmlDomMeta = []; delete context.inputsHandler; delete context.updatesHandler; // context.value.destroy(context, ownerSupport) } export function processFirstSubjectComponent(templater, subject, ownerSupport, _appendTo) { const support = createSupportWithProps(templater, subject, ownerSupport); return convertTagToElementManaged(support, ownerSupport, subject); } //# sourceMappingURL=processFirstSubjectComponent.function.js.map