chore: Merge branch 'edison/fix/codegenOrder' into edison/testVapor

This commit is contained in:
daiwei 2025-08-01 16:19:01 +08:00
commit f2cdbe0387
4 changed files with 10 additions and 15 deletions

View File

@ -213,16 +213,18 @@ export function render(_ctx) {
`; `;
exports[`compile > execution order > with insertionState 1`] = ` exports[`compile > execution order > with insertionState 1`] = `
"import { resolveComponent as _resolveComponent, setInsertionState as _setInsertionState, createSlot as _createSlot, createComponentWithFallback as _createComponentWithFallback, template as _template } from 'vue'; "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>") const t0 = _template("<div><div></div></div>", true)
export function render(_ctx) { export function render(_ctx) {
const _component_Comp = _resolveComponent("Comp") const _component_Comp = _resolveComponent("Comp")
const n1 = t0() const n3 = t0()
const n1 = _child(n3)
_setInsertionState(n1) _setInsertionState(n1)
const n0 = _createSlot("default", null) const n0 = _createSlot("default", null)
_setInsertionState(n3)
const n2 = _createComponentWithFallback(_component_Comp) const n2 = _createComponentWithFallback(_component_Comp)
return [n1, n2] return n3
}" }"
`; `;

View File

@ -264,7 +264,7 @@ describe('compile', () => {
}) })
test('with insertionState', () => { test('with insertionState', () => {
const code = compile(`<div><slot /></div><Comp/>`) const code = compile(`<div><div><slot /></div><Comp/></div>`)
expect(code).matchSnapshot() expect(code).matchSnapshot()
}) })
}) })

View File

@ -57,10 +57,10 @@ const t0 = _template("<div><div>x</div><div><span> </span></div><div><span> </sp
export function render(_ctx) { export function render(_ctx) {
const n3 = t0() const n3 = t0()
const p0 = _next(_child(n3)) const p0 = _next(_child(n3))
const p1 = _next(p0)
const p2 = _next(p1)
const n0 = _child(p0) const n0 = _child(p0)
const p1 = _next(p0)
const n1 = _child(p1) const n1 = _child(p1)
const p2 = _next(p1)
const n2 = _child(p2) const n2 = _child(p2)
const x0 = _child(n0) const x0 = _child(n0)
const x1 = _child(n1) const x1 = _child(n1)

View File

@ -55,7 +55,6 @@ export function genChildren(
let offset = 0 let offset = 0
let prev: [variable: string, elementIndex: number] | undefined let prev: [variable: string, elementIndex: number] | undefined
const childrenToGen: [IRDynamicInfo, string][] = []
for (const [index, child] of children.entries()) { for (const [index, child] of children.entries()) {
if (child.flags & DynamicFlag.NON_TEMPLATE) { if (child.flags & DynamicFlag.NON_TEMPLATE) {
@ -123,13 +122,7 @@ export function genChildren(
} }
prev = [variable, elementIndex] prev = [variable, elementIndex]
childrenToGen.push([child, variable]) push(...genChildren(child, context, pushBlock, variable))
}
if (childrenToGen.length) {
for (const [child, from] of childrenToGen) {
push(...genChildren(child, context, pushBlock, from))
}
} }
return frag return frag