Skip to content

Commit 6a43377

Browse files
committed
fix: Support camelCase directives
1 parent 5f4c024 commit 6a43377

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

Diff for: packages/babel-plugin-transform-vue-jsx/src/index.js

+3
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ const parseAttributeJSXAttribute = (t, path, attributes, tagName, elementType) =
161161
if (name.startsWith(`v-`)) {
162162
name = name.replace(directiveRE, '')
163163
prefix = 'directives'
164+
} else if (name.startsWith('v') && name.length >= 2 && name[1] >= 'A' && name[1] <= 'Z') {
165+
name = name[1].toLowerCase() + name.substr(2)
166+
prefix = 'directives'
164167
}
165168
if (name.match(xlinkRE)) {
166169
name = name.replace(xlinkRE, (_, firstCharacter) => {

Diff for: packages/babel-plugin-transform-vue-jsx/test/functional.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ test('Spread (mixed)', t => {
234234
test('Custom directives', t => {
235235
const wrapper = shallow({
236236
render(h) {
237-
return <div v-test={123} v-other={234} />
237+
return <div v-test={123} vOther={234} />
238238
},
239239
})
240240

Diff for: packages/babel-plugin-transform-vue-jsx/test/snapshot.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ render(h => h("div", _mergeJSXProps([{}, spread, {
215215
},
216216
{
217217
name: 'Directives',
218-
from: `render(h => <div v-test={ 123 } v-other={ 234 } />)`,
218+
from: `render(h => <div v-test={ 123 } vOther={ 234 } />)`,
219219
to: `render(h => h("div", {
220220
"directives": [{
221221
name: "test",

0 commit comments

Comments
 (0)