Skip to content

Commit a903610

Browse files
committed
fix: proper support for camelCase
1 parent 6a43377 commit a903610

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

Diff for: packages/babel-plugin-transform-vue-jsx/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
"dependencies": {
3737
"@babel/helper-module-imports": "^7.0.0-beta.49",
3838
"@babel/plugin-syntax-jsx": "^7.0.0-beta.49",
39-
"@vuejs/babel-helper-vue-jsx-merge-props": "^0.1.0"
39+
"@vuejs/babel-helper-vue-jsx-merge-props": "^0.1.0",
40+
"lodash.kebabcase": "^4.1.1"
4041
},
4142
"nyc": {
4243
"exclude": [

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import syntaxJsx from '@babel/plugin-syntax-jsx'
22
import { addDefault } from '@babel/helper-module-imports'
3+
import kebabcase from 'lodash.kebabcase'
34

45
const xlinkRE = /^xlink([A-Z])/
56
const directiveRE = /^v-/
@@ -162,7 +163,7 @@ const parseAttributeJSXAttribute = (t, path, attributes, tagName, elementType) =
162163
name = name.replace(directiveRE, '')
163164
prefix = 'directives'
164165
} else if (name.startsWith('v') && name.length >= 2 && name[1] >= 'A' && name[1] <= 'Z') {
165-
name = name[1].toLowerCase() + name.substr(2)
166+
name = kebabcase(name.substr(1))
166167
prefix = 'directives'
167168
}
168169
if (name.match(xlinkRE)) {

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -215,13 +215,13 @@ render(h => h("div", _mergeJSXProps([{}, spread, {
215215
},
216216
{
217217
name: 'Directives',
218-
from: `render(h => <div v-test={ 123 } vOther={ 234 } />)`,
218+
from: `render(h => <div v-test={ 123 } vOtherStuff={ 234 } />)`,
219219
to: `render(h => h("div", {
220220
"directives": [{
221221
name: "test",
222222
value: 123
223223
}, {
224-
name: "other",
224+
name: "other-stuff",
225225
value: 234
226226
}]
227227
}));`,

Diff for: packages/babel-plugin-transform-vue-jsx/yarn.lock

+4
Original file line numberDiff line numberDiff line change
@@ -2929,6 +2929,10 @@ lodash.isequal@^4.5.0:
29292929
version "4.5.0"
29302930
resolved "https://registry.yarnpkg.com/lodash.isequal/-/lodash.isequal-4.5.0.tgz#415c4478f2bcc30120c22ce10ed3226f7d3e18e0"
29312931

2932+
lodash.kebabcase@^4.1.1:
2933+
version "4.1.1"
2934+
resolved "https://registry.yarnpkg.com/lodash.kebabcase/-/lodash.kebabcase-4.1.1.tgz#8489b1cb0d29ff88195cceca448ff6d6cc295c36"
2935+
29322936
lodash.merge@^4.6.0:
29332937
version "4.6.1"
29342938
resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.1.tgz#adc25d9cb99b9391c59624f379fbba60d7111d54"

0 commit comments

Comments
 (0)