mirror of https://github.com/vuejs/core.git
refactor(compiler-vapor): new dynamic info
This commit is contained in:
parent
784310d4dc
commit
d535c647be
|
@ -25,7 +25,7 @@ import {
|
||||||
type VaporDirectiveNode,
|
type VaporDirectiveNode,
|
||||||
} from './ir'
|
} from './ir'
|
||||||
import { isConstantExpression } from './utils'
|
import { isConstantExpression } from './utils'
|
||||||
import { genDefaultDynamic } from './transforms/utils'
|
import { newDynamic } from './transforms/utils'
|
||||||
|
|
||||||
export type NodeTransform = (
|
export type NodeTransform = (
|
||||||
node: RootNode | TemplateChildNode,
|
node: RootNode | TemplateChildNode,
|
||||||
|
@ -174,7 +174,7 @@ export class TransformContext<T extends AllNode = AllNode> {
|
||||||
|
|
||||||
template: '',
|
template: '',
|
||||||
childrenTemplate: [],
|
childrenTemplate: [],
|
||||||
dynamic: genDefaultDynamic(),
|
dynamic: newDynamic(),
|
||||||
} satisfies Partial<TransformContext<T>>)
|
} satisfies Partial<TransformContext<T>>)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -217,9 +217,7 @@ export function transform(
|
||||||
block: {
|
block: {
|
||||||
type: IRNodeTypes.BLOCK,
|
type: IRNodeTypes.BLOCK,
|
||||||
node: root,
|
node: root,
|
||||||
dynamic: extend(genDefaultDynamic(), {
|
dynamic: newDynamic(),
|
||||||
flags: DynamicFlag.REFERENCED,
|
|
||||||
} satisfies Partial<IRDynamicInfo>),
|
|
||||||
effect: [],
|
effect: [],
|
||||||
operation: [],
|
operation: [],
|
||||||
returns: [],
|
returns: [],
|
||||||
|
|
|
@ -11,8 +11,8 @@ import {
|
||||||
import { extend } from '@vue/shared'
|
import { extend } from '@vue/shared'
|
||||||
import { DynamicFlag, type IRDynamicInfo } from '../ir'
|
import { DynamicFlag, type IRDynamicInfo } from '../ir'
|
||||||
|
|
||||||
export const genDefaultDynamic = (): IRDynamicInfo => ({
|
export const newDynamic = (): IRDynamicInfo => ({
|
||||||
flags: DynamicFlag.NONE,
|
flags: DynamicFlag.REFERENCED,
|
||||||
children: [],
|
children: [],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -11,13 +11,11 @@ import {
|
||||||
import {
|
import {
|
||||||
type BlockIRNode,
|
type BlockIRNode,
|
||||||
DynamicFlag,
|
DynamicFlag,
|
||||||
type IRDynamicInfo,
|
|
||||||
IRNodeTypes,
|
IRNodeTypes,
|
||||||
type VaporDirectiveNode,
|
type VaporDirectiveNode,
|
||||||
} from '../ir'
|
} from '../ir'
|
||||||
import { extend } from '@vue/shared'
|
|
||||||
import { findProp, propToExpression } from '../utils'
|
import { findProp, propToExpression } from '../utils'
|
||||||
import { genDefaultDynamic, wrapTemplate } from './utils'
|
import { newDynamic, wrapTemplate } from './utils'
|
||||||
|
|
||||||
export const transformVFor = createStructuralDirectiveTransform(
|
export const transformVFor = createStructuralDirectiveTransform(
|
||||||
'for',
|
'for',
|
||||||
|
@ -53,9 +51,7 @@ export function processFor(
|
||||||
const render: BlockIRNode = {
|
const render: BlockIRNode = {
|
||||||
type: IRNodeTypes.BLOCK,
|
type: IRNodeTypes.BLOCK,
|
||||||
node,
|
node,
|
||||||
dynamic: extend(genDefaultDynamic(), {
|
dynamic: newDynamic(),
|
||||||
flags: DynamicFlag.REFERENCED,
|
|
||||||
} satisfies Partial<IRDynamicInfo>),
|
|
||||||
effect: [],
|
effect: [],
|
||||||
operation: [],
|
operation: [],
|
||||||
returns: [],
|
returns: [],
|
||||||
|
|
|
@ -11,12 +11,11 @@ import {
|
||||||
import {
|
import {
|
||||||
type BlockIRNode,
|
type BlockIRNode,
|
||||||
DynamicFlag,
|
DynamicFlag,
|
||||||
type IRDynamicInfo,
|
|
||||||
IRNodeTypes,
|
IRNodeTypes,
|
||||||
type VaporDirectiveNode,
|
type VaporDirectiveNode,
|
||||||
} from '../ir'
|
} from '../ir'
|
||||||
import { extend } from '@vue/shared'
|
import { extend } from '@vue/shared'
|
||||||
import { genDefaultDynamic, wrapTemplate } from './utils'
|
import { newDynamic, wrapTemplate } from './utils'
|
||||||
import { getSiblingIf } from './transformComment'
|
import { getSiblingIf } from './transformComment'
|
||||||
|
|
||||||
export const transformVIf = createStructuralDirectiveTransform(
|
export const transformVIf = createStructuralDirectiveTransform(
|
||||||
|
@ -118,9 +117,7 @@ export function createIfBranch(
|
||||||
const branch: BlockIRNode = {
|
const branch: BlockIRNode = {
|
||||||
type: IRNodeTypes.BLOCK,
|
type: IRNodeTypes.BLOCK,
|
||||||
node,
|
node,
|
||||||
dynamic: extend(genDefaultDynamic(), {
|
dynamic: newDynamic(),
|
||||||
flags: DynamicFlag.REFERENCED,
|
|
||||||
} satisfies Partial<IRDynamicInfo>),
|
|
||||||
effect: [],
|
effect: [],
|
||||||
operation: [],
|
operation: [],
|
||||||
returns: [],
|
returns: [],
|
||||||
|
|
Loading…
Reference in New Issue