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