}"
`;
+exports[`compile > execution order > with insertionState 1`] = `
+"import { resolveComponent as _resolveComponent, child as _child, setInsertionState as _setInsertionState, createSlot as _createSlot, createComponentWithFallback as _createComponentWithFallback, template as _template } from 'vue';
+const t0 = _template("<div><div></div></div>", true)
+
+export function render(_ctx) {
+ const _component_Comp = _resolveComponent("Comp")
+ const n3 = t0()
+ const n1 = _child(n3)
+ _setInsertionState(n1)
+ const n0 = _createSlot("default", null)
+ _setInsertionState(n3)
+ const n2 = _createComponentWithFallback(_component_Comp)
+ return n3
+}"
+`;
+
exports[`compile > execution order > with v-once 1`] = `
"import { child as _child, next as _next, nthChild as _nthChild, toDisplayString as _toDisplayString, setText as _setText, renderEffect as _renderEffect, template as _template } from 'vue';
const t0 = _template("<div><span> </span> <br> </div>", true)
_setText(x0, _toDisplayString(_ctx.bar))`,
)
})
+
test('with v-once', () => {
const code = compile(
`<div>
_setText(n2, " " + _toDisplayString(_ctx.baz))`,
)
})
+
+ test('with insertionState', () => {
+ const code = compile(`<div><div><slot /></div><Comp/></div>`)
+ expect(code).matchSnapshot()
+ })
})
})
push(...genSelf(child, context))
}
for (const child of dynamic.children) {
- push(...genChildren(child, context, push, `n${child.id!}`))
+ if (!child.hasDynamicChild) {
+ push(...genChildren(child, context, push, `n${child.id!}`))
+ }
}
push(...genOperations(operation, context))
context: CodegenContext,
): CodeFragment[] {
const [frag, push] = buildCodeFragment()
- const { id, template, operation } = dynamic
+ const { id, template, operation, hasDynamicChild } = dynamic
if (id !== undefined && template !== undefined) {
push(NEWLINE, `const n${id} = t${template}()`)
push(...genOperationWithInsertionState(operation, context))
}
+ if (hasDynamicChild) {
+ push(...genChildren(dynamic, context, push, `n${id}`))
+ }
+
return frag
}
let offset = 0
let prev: [variable: string, elementIndex: number] | undefined
- const childrenToGen: [IRDynamicInfo, string][] = []
for (const [index, child] of children.entries()) {
if (child.flags & DynamicFlag.NON_TEMPLATE) {
}
}
- if (id === child.anchor) {
+ if (id === child.anchor && !child.hasDynamicChild) {
push(...genSelf(child, context))
}
}
prev = [variable, elementIndex]
- childrenToGen.push([child, variable])
- }
-
- if (childrenToGen.length) {
- for (const [child, from] of childrenToGen) {
- push(...genChildren(child, context, pushBlock, from))
- }
+ push(...genChildren(child, context, pushBlock, variable))
}
return frag