UNPKG

taggedjs

Version:

tagged template reactive html

45 lines 1.79 kB
import { getNewGlobal } from './update/getNewGlobal.function.js'; import { destroySupport } from '../render/destroySupport.function.js'; import { isStaticTag } from '../isInstance.js'; import { isLikeTags } from './isLikeTags.function.js'; import { tryUpdateToTag } from './update/tryUpdateToTag.function.js'; export function checkTagValueChange(newValue, contextItem, counts) { const global = contextItem.global; const lastSupport = global?.newest; const isValueTag = isStaticTag(newValue); const newTag = newValue; if (isValueTag) { // its a different tag now const likeTags = isLikeTags(newTag, lastSupport); if (!likeTags) { destroySupport(lastSupport, global); getNewGlobal(contextItem); return 7; // 'tag-swap' } // always cause a redraw of static tags (was false) tryUpdateToTag(contextItem, newValue, lastSupport, counts); return -1; } const isTag = newValue?.tagJsType; if (isTag) { const support = global.newest; const ownerSupport = support.ownerSupport; const result = tryUpdateToTag(contextItem, newValue, ownerSupport, counts); const doNotRedraw = result === true; if (doNotRedraw) { return -1; } return 88; // its same tag with new values } destroySupportByContextItem(contextItem); return 8; // 'no-longer-tag' } export function destroySupportByContextItem(contextItem) { const global = contextItem.global; const lastSupport = global?.newest; // destroy old component, value is not a component destroySupport(lastSupport, global); delete contextItem.global; contextItem.renderCount = 0; } //# sourceMappingURL=checkTagValueChange.function.js.map