Skip to content

Commit

Permalink
fix: AST should not be mutated
Browse files Browse the repository at this point in the history
  • Loading branch information
LittleSound committed Apr 29, 2024
1 parent a5d6457 commit e4df821
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
12 changes: 7 additions & 5 deletions packages/compiler-vapor/src/transforms/transformSlotOutlet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ export const transformSlotOutlet: NodeTransform = (node, context) => {
if (prop.name === 'name') {
name = createSimpleExpression(prop.value.content, true, prop.loc)
} else {
prop.name = camelize(prop.name)
nonNameProps.push(prop)
nonNameProps.push(extend({}, prop, { name: camelize(prop.name) }))
}
}
} else if (prop.name === 'bind' && isStaticArgOf(prop.arg, 'name')) {
Expand All @@ -63,10 +62,13 @@ export const transformSlotOutlet: NodeTransform = (node, context) => {
} else if (!isBuiltInDirective(prop.name)) {
directives.push(prop)
} else {
if (prop.name === 'bind' && prop.arg && isStaticExp(prop.arg)) {
prop.arg.content = camelize(prop.arg.content)
const nonProp = extend({}, prop)
if (nonProp.name === 'bind' && nonProp.arg && isStaticExp(nonProp.arg)) {
nonProp.arg = extend({}, nonProp.arg, {
content: camelize(nonProp.arg.content),
})
}
nonNameProps.push(prop)
nonNameProps.push(nonProp)
}
}

Expand Down
4 changes: 2 additions & 2 deletions packages/compiler-vapor/src/transforms/vBind.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
createCompilerError,
createSimpleExpression,
} from '@vue/compiler-dom'
import { camelize } from '@vue/shared'
import { camelize, extend } from '@vue/shared'
import type { DirectiveTransform, TransformContext } from '../transform'
import { resolveExpression } from '../utils'
import { isReservedProp } from './transformElement'
Expand Down Expand Up @@ -58,7 +58,7 @@ export const transformVBind: DirectiveTransform = (dir, node, context) => {
let camel = false
if (modifiers.includes('camel')) {
if (arg.isStatic) {
arg.content = camelize(arg.content)
arg = extend({}, arg, { content: camelize(arg.content) })
} else {
camel = true
}
Expand Down

0 comments on commit e4df821

Please sign in to comment.