UNPKG

taggedjs

Version:

tagged template reactive html

32 lines 1.34 kB
import { BasicTypes, ValueTypes } from '../tag/ValueTypes.enum.js'; import { setUseMemory } from '../state/setUseMemory.object.js'; import { setSupportInCycle } from '../tag/cycles/getSupportInCycle.function.js'; import { removeContextInCycle } from '../tag/cycles/setContextInCycle.function.js'; export function executeWrap(templater, result, useSupport, castedProps) { const originalFunction = result.original; // (innerTagWrap as any).original as unknown as TagComponent const stateless = templater.tagJsType === ValueTypes.stateRender; const config = setUseMemory.stateConfig; setSupportInCycle(useSupport); let tag; if (stateless) { tag = templater(); } else { tag = originalFunction(...castedProps); // tag returns another function expected to be called if (typeof (tag) === BasicTypes.function && tag.tagJsType === undefined) { tag = tag(); } } if (!tag) { throw new Error(`A tag cannot return a value of type ${tag === null ? 'null' : typeof (tag)}`); } const context = useSupport.context; context.returnValue = tag; useSupport.returnValue = tag; templater.tag = tag; context.state.newer = { ...config }; removeContextInCycle(); return useSupport; } //# sourceMappingURL=executeWrap.function.js.map