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 {
|
import {
|
||||||
type BlockFunctionIRNode,
|
type BlockFunctionIRNode,
|
||||||
DynamicFlag,
|
DynamicFlag,
|
||||||
type IRDynamicChildren,
|
type IRDynamicInfo,
|
||||||
IRNodeTypes,
|
IRNodeTypes,
|
||||||
type OperationNode,
|
type OperationNode,
|
||||||
type RootIRNode,
|
type RootIRNode,
|
||||||
|
@ -313,20 +313,23 @@ export function generate(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function genChildren(children: IRDynamicChildren) {
|
function genChildren(children: IRDynamicInfo[]) {
|
||||||
let code = ''
|
let code = ''
|
||||||
let offset = 0
|
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) {
|
if (child.dynamicFlags & DynamicFlag.NON_TEMPLATE) {
|
||||||
offset--
|
offset--
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const idx = Number(index) + offset
|
const idx = Number(index) + offset
|
||||||
const id =
|
const id =
|
||||||
child.dynamicFlags & DynamicFlag.INSERT ? child.placeholder : child.id
|
child.dynamicFlags & DynamicFlag.REFERENCED
|
||||||
const childrenString = childrenLength && genChildren(child.children)
|
? child.dynamicFlags & DynamicFlag.INSERT
|
||||||
|
? child.anchor
|
||||||
|
: child.id
|
||||||
|
: null
|
||||||
|
const childrenString = genChildren(child.children)
|
||||||
|
|
||||||
if (id !== null || childrenString) {
|
if (id !== null || childrenString) {
|
||||||
code += ` ${idx}: [`
|
code += ` ${idx}: [`
|
||||||
|
|
|
@ -199,7 +199,7 @@ export enum DynamicFlag {
|
||||||
export interface IRDynamicInfo {
|
export interface IRDynamicInfo {
|
||||||
id: number | null
|
id: number | null
|
||||||
dynamicFlags: DynamicFlag
|
dynamicFlags: DynamicFlag
|
||||||
placeholder: number | null
|
anchor: number | null
|
||||||
children: IRDynamicInfo[]
|
children: IRDynamicInfo[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,7 @@ const defaultOptions = {
|
||||||
export const genDefaultDynamic = (): IRDynamicInfo => ({
|
export const genDefaultDynamic = (): IRDynamicInfo => ({
|
||||||
id: null,
|
id: null,
|
||||||
dynamicFlags: 0,
|
dynamicFlags: 0,
|
||||||
placeholder: null,
|
anchor: null,
|
||||||
children: [],
|
children: [],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -335,7 +335,9 @@ function processDynamicChildren(ctx: TransformContext<RootNode | ElementNode>) {
|
||||||
if (prevChildren.length) {
|
if (prevChildren.length) {
|
||||||
if (hasStatic) {
|
if (hasStatic) {
|
||||||
ctx.childrenTemplate[index - prevChildren.length] = `<!>`
|
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({
|
ctx.registerOperation({
|
||||||
type: IRNodeTypes.INSERT_NODE,
|
type: IRNodeTypes.INSERT_NODE,
|
||||||
|
|
Loading…
Reference in New Issue