fix(compiler-dom): fix duplicated transforms
This commit is contained in:
parent
a51e710396
commit
9e51297702
@ -6,8 +6,8 @@ import {
|
|||||||
ParserOptions,
|
ParserOptions,
|
||||||
RootNode,
|
RootNode,
|
||||||
noopDirectiveTransform,
|
noopDirectiveTransform,
|
||||||
TransformPreset,
|
NodeTransform,
|
||||||
getBaseTransformPreset
|
DirectiveTransform
|
||||||
} from '@vue/compiler-core'
|
} from '@vue/compiler-core'
|
||||||
import { parserOptionsMinimal } from './parserOptionsMinimal'
|
import { parserOptionsMinimal } from './parserOptionsMinimal'
|
||||||
import { parserOptionsStandard } from './parserOptionsStandard'
|
import { parserOptionsStandard } from './parserOptionsStandard'
|
||||||
@ -23,43 +23,30 @@ export const parserOptions = __BROWSER__
|
|||||||
? parserOptionsMinimal
|
? parserOptionsMinimal
|
||||||
: parserOptionsStandard
|
: parserOptionsStandard
|
||||||
|
|
||||||
export function getDOMTransformPreset(
|
export const DOMNodeTransforms: NodeTransform[] = [
|
||||||
prefixIdentifiers?: boolean
|
transformStyle,
|
||||||
): TransformPreset {
|
...(__DEV__ ? [warnTransitionChildren] : [])
|
||||||
const [nodeTransforms, directiveTransforms] = getBaseTransformPreset(
|
]
|
||||||
prefixIdentifiers
|
|
||||||
)
|
export const DOMDirectiveTransforms: Record<string, DirectiveTransform> = {
|
||||||
return [
|
cloak: noopDirectiveTransform,
|
||||||
[
|
html: transformVHtml,
|
||||||
...nodeTransforms,
|
text: transformVText,
|
||||||
transformStyle,
|
model: transformModel, // override compiler-core
|
||||||
...(__DEV__ ? [warnTransitionChildren] : [])
|
on: transformOn, // override compiler-core
|
||||||
],
|
show: transformShow
|
||||||
{
|
|
||||||
...directiveTransforms,
|
|
||||||
cloak: noopDirectiveTransform,
|
|
||||||
html: transformVHtml,
|
|
||||||
text: transformVText,
|
|
||||||
model: transformModel, // override compiler-core
|
|
||||||
on: transformOn, // override compiler-core
|
|
||||||
show: transformShow
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function compile(
|
export function compile(
|
||||||
template: string,
|
template: string,
|
||||||
options: CompilerOptions = {}
|
options: CompilerOptions = {}
|
||||||
): CodegenResult {
|
): CodegenResult {
|
||||||
const [nodeTransforms, directiveTransforms] = getDOMTransformPreset(
|
|
||||||
options.prefixIdentifiers
|
|
||||||
)
|
|
||||||
return baseCompile(template, {
|
return baseCompile(template, {
|
||||||
...parserOptions,
|
...parserOptions,
|
||||||
...options,
|
...options,
|
||||||
nodeTransforms: [...nodeTransforms, ...(options.nodeTransforms || [])],
|
nodeTransforms: [...DOMNodeTransforms, ...(options.nodeTransforms || [])],
|
||||||
directiveTransforms: {
|
directiveTransforms: {
|
||||||
...directiveTransforms,
|
...DOMDirectiveTransforms,
|
||||||
...(options.directiveTransforms || {})
|
...(options.directiveTransforms || {})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -16,7 +16,9 @@ import {
|
|||||||
TRANSITION_GROUP,
|
TRANSITION_GROUP,
|
||||||
createIfStatement,
|
createIfStatement,
|
||||||
createSimpleExpression,
|
createSimpleExpression,
|
||||||
getDOMTransformPreset,
|
getBaseTransformPreset,
|
||||||
|
DOMNodeTransforms,
|
||||||
|
DOMDirectiveTransforms,
|
||||||
createReturnStatement,
|
createReturnStatement,
|
||||||
ReturnStatement,
|
ReturnStatement,
|
||||||
Namespaces,
|
Namespaces,
|
||||||
@ -165,9 +167,14 @@ export function ssrProcessComponent(
|
|||||||
|
|
||||||
export const rawOptionsMap = new WeakMap<RootNode, CompilerOptions>()
|
export const rawOptionsMap = new WeakMap<RootNode, CompilerOptions>()
|
||||||
|
|
||||||
const [vnodeNodeTransforms, vnodeDirectiveTransforms] = getDOMTransformPreset(
|
const [baseNodeTransforms, baseDirectiveTransforms] = getBaseTransformPreset(
|
||||||
true
|
true
|
||||||
)
|
)
|
||||||
|
const vnodeNodeTransforms = [...baseNodeTransforms, ...DOMNodeTransforms]
|
||||||
|
const vnodeDirectiveTransforms = {
|
||||||
|
...baseDirectiveTransforms,
|
||||||
|
...DOMDirectiveTransforms
|
||||||
|
}
|
||||||
|
|
||||||
function createVNodeSlotBranch(
|
function createVNodeSlotBranch(
|
||||||
props: ExpressionNode | undefined,
|
props: ExpressionNode | undefined,
|
||||||
|
Loading…
Reference in New Issue
Block a user