Skip to content
This repository was archived by the owner on Jul 19, 2025. It is now read-only.

Commit af855de

Browse files
committed
fix: AST should not be mutated
1 parent 8cef55e commit af855de

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

packages/compiler-vapor/src/transforms/transformSlotOutlet.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ export const transformSlotOutlet: NodeTransform = (node, context) => {
4444
if (prop.name === 'name') {
4545
name = createSimpleExpression(prop.value.content, true, prop.loc)
4646
} else {
47-
prop.name = camelize(prop.name)
48-
nonNameProps.push(prop)
47+
nonNameProps.push(extend({}, prop, { name: camelize(prop.name) }))
4948
}
5049
}
5150
} else if (prop.name === 'bind' && isStaticArgOf(prop.arg, 'name')) {
@@ -63,10 +62,13 @@ export const transformSlotOutlet: NodeTransform = (node, context) => {
6362
} else if (!isBuiltInDirective(prop.name)) {
6463
directives.push(prop)
6564
} else {
66-
if (prop.name === 'bind' && prop.arg && isStaticExp(prop.arg)) {
67-
prop.arg.content = camelize(prop.arg.content)
65+
const nonProp = extend({}, prop)
66+
if (nonProp.name === 'bind' && nonProp.arg && isStaticExp(nonProp.arg)) {
67+
nonProp.arg = extend({}, nonProp.arg, {
68+
content: camelize(nonProp.arg.content),
69+
})
6870
}
69-
nonNameProps.push(prop)
71+
nonNameProps.push(nonProp)
7072
}
7173
}
7274

packages/compiler-vapor/src/transforms/vBind.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
createCompilerError,
66
createSimpleExpression,
77
} from '@vue/compiler-dom'
8-
import { camelize } from '@vue/shared'
8+
import { camelize, extend } from '@vue/shared'
99
import type { DirectiveTransform, TransformContext } from '../transform'
1010
import { resolveExpression } from '../utils'
1111
import { isReservedProp } from './transformElement'
@@ -58,7 +58,7 @@ export const transformVBind: DirectiveTransform = (dir, node, context) => {
5858
let camel = false
5959
if (modifiers.includes('camel')) {
6060
if (arg.isStatic) {
61-
arg.content = camelize(arg.content)
61+
arg = extend({}, arg, { content: camelize(arg.content) })
6262
} else {
6363
camel = true
6464
}

0 commit comments

Comments
 (0)