mirror of https://github.com/vuejs/core.git
fix(compiler-vapor): handle no template
This commit is contained in:
parent
ed9368c06c
commit
48d2aa3bcb
|
@ -10,7 +10,7 @@ import {
|
|||
import {
|
||||
type BlockFunctionIRNode,
|
||||
DynamicFlag,
|
||||
type IRDynamicChildren,
|
||||
type IRDynamicInfo,
|
||||
IRNodeTypes,
|
||||
type OperationNode,
|
||||
type RootIRNode,
|
||||
|
@ -313,20 +313,23 @@ export function generate(
|
|||
}
|
||||
}
|
||||
|
||||
function genChildren(children: IRDynamicChildren) {
|
||||
function genChildren(children: IRDynamicInfo[]) {
|
||||
let code = ''
|
||||
let offset = 0
|
||||
for (const [index, child] of Object.entries(children)) {
|
||||
const childrenLength = Object.keys(child.children).length
|
||||
|
||||
for (const [index, child] of children.entries()) {
|
||||
if (child.dynamicFlags & DynamicFlag.NON_TEMPLATE) {
|
||||
offset--
|
||||
continue
|
||||
}
|
||||
|
||||
const idx = Number(index) + offset
|
||||
const id =
|
||||
child.dynamicFlags & DynamicFlag.INSERT ? child.placeholder : child.id
|
||||
const childrenString = childrenLength && genChildren(child.children)
|
||||
child.dynamicFlags & DynamicFlag.REFERENCED
|
||||
? child.dynamicFlags & DynamicFlag.INSERT
|
||||
? child.anchor
|
||||
: child.id
|
||||
: null
|
||||
const childrenString = genChildren(child.children)
|
||||
|
||||
if (id !== null || childrenString) {
|
||||
code += ` ${idx}: [`
|
||||
|
|
|
@ -199,7 +199,7 @@ export enum DynamicFlag {
|
|||
export interface IRDynamicInfo {
|
||||
id: number | null
|
||||
dynamicFlags: DynamicFlag
|
||||
placeholder: number | null
|
||||
anchor: number | null
|
||||
children: IRDynamicInfo[]
|
||||
}
|
||||
|
||||
|
|
|
@ -102,7 +102,7 @@ const defaultOptions = {
|
|||
export const genDefaultDynamic = (): IRDynamicInfo => ({
|
||||
id: null,
|
||||
dynamicFlags: 0,
|
||||
placeholder: null,
|
||||
anchor: null,
|
||||
children: [],
|
||||
})
|
||||
|
||||
|
@ -335,7 +335,9 @@ function processDynamicChildren(ctx: TransformContext<RootNode | ElementNode>) {
|
|||
if (prevChildren.length) {
|
||||
if (hasStatic) {
|
||||
ctx.childrenTemplate[index - prevChildren.length] = `<!>`
|
||||
const anchor = (prevChildren[0].placeholder = ctx.increaseId())
|
||||
|
||||
prevChildren[0].dynamicFlags -= DynamicFlag.NON_TEMPLATE
|
||||
const anchor = (prevChildren[0].anchor = ctx.increaseId())
|
||||
|
||||
ctx.registerOperation({
|
||||
type: IRNodeTypes.INSERT_NODE,
|
||||
|
|
Loading…
Reference in New Issue