Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -361,13 +361,24 @@ export function render(_ctx) {
}"
`;

exports[`compiler v-bind > .camel modifier w/ dynamic arg + prefixIdentifiers 1`] = `
"import { camelize as _camelize, setDynamicProps as _setDynamicProps, renderEffect as _renderEffect, template as _template } from 'vue';
const t0 = _template("<div></div>", true)

export function render(_ctx) {
const n0 = t0()
_renderEffect(() => _setDynamicProps(n0, [{ [_camelize(_ctx.foo(_ctx.bar) || "")]: _ctx.id }]))
return n0
}"
`;

exports[`compiler v-bind > .camel modifier w/ dynamic arg 1`] = `
"import { camelize as _camelize, setDynamicProps as _setDynamicProps, renderEffect as _renderEffect, template as _template } from 'vue';
const t0 = _template("<div></div>", true)

export function render(_ctx) {
const n0 = t0()
_renderEffect(() => _setDynamicProps(n0, [{ [_camelize(_ctx.foo)]: _ctx.id }]))
_renderEffect(() => _setDynamicProps(n0, [{ [_camelize(_ctx.foo || "")]: _ctx.id }]))
return n0
}"
`;
Expand Down
33 changes: 31 additions & 2 deletions packages/compiler-vapor/__tests__/transforms/vBind.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,11 +341,40 @@ describe('compiler v-bind', () => {
expect(code).matchSnapshot()
expect(code).contains('renderEffect')
expect(code).contains(
`_setDynamicProps(n0, [{ [_camelize(_ctx.foo)]: _ctx.id }])`,
`_setDynamicProps(n0, [{ [_camelize(_ctx.foo || "")]: _ctx.id }])`,
)
})

test.todo('.camel modifier w/ dynamic arg + prefixIdentifiers')
test('.camel modifier w/ dynamic arg + prefixIdentifiers', () => {
const { ir, code } = compileWithVBind(
`<div v-bind:[foo(bar)].camel="id"/>`,
{
prefixIdentifiers: true,
},
)
expect(code).matchSnapshot()
expect(ir.block.effect[0].operations[0]).toMatchObject({
type: IRNodeTypes.SET_DYNAMIC_PROPS,
props: [
[
{
key: {
content: `foo(bar)`,
isStatic: false,
},
values: [
{
content: `id`,
isStatic: false,
},
],
runtimeCamelize: true,
modifier: undefined,
},
],
],
})
})

test('.prop modifier', () => {
const { ir, code } = compileWithVBind(`<div v-bind:fooBar.prop="id"/>`)
Expand Down
1 change: 1 addition & 0 deletions packages/compiler-vapor/src/generators/prop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ export function genPropKey(

let key = genExpression(node, context)
if (runtimeCamelize) {
key.push(' || ""')
key = genCall(helper('camelize'), key)
}
if (handler) {
Expand Down
Loading