File tree 4 files changed +29
-4
lines changed
packages/babel-sugar-v-model
4 files changed +29
-4
lines changed Original file line number Diff line number Diff line change 37
37
"@babel/plugin-syntax-jsx" : " ^7.0.0-rc.3" ,
38
38
"@vue/babel-helper-vue-jsx-merge-props" : " ^0.1.0" ,
39
39
"@vue/babel-plugin-transform-vue-jsx" : " ^0.1.0" ,
40
- "camelcase" : " ^5.0.0"
40
+ "camelcase" : " ^5.0.0" ,
41
+ "html-tags" : " ^2.0.0" ,
42
+ "svg-tags" : " ^1.0.0"
41
43
},
42
44
"nyc" : {
43
45
"exclude" : [
Original file line number Diff line number Diff line change 1
1
import camelCase from 'camelcase'
2
2
import syntaxJsx from '@babel/plugin-syntax-jsx'
3
+ import htmlTags from 'html-tags'
4
+ import svgTags from 'svg-tags'
3
5
4
6
const RANGE_TOKEN = '__r'
5
7
@@ -109,10 +111,11 @@ const isComponent = (t, path) => {
109
111
const name = path . get ( 'name' )
110
112
if ( t . isJSXMemberExpression ( name ) ) {
111
113
return true
112
- } else {
113
- const firstChar = name . get ( 'name' ) . node [ 0 ]
114
- return firstChar >= 'A' && firstChar <= 'Z'
115
114
}
115
+
116
+ const tag = name . get ( 'name' ) . node
117
+
118
+ return ! htmlTags . includes ( tag ) && ! svgTags . includes ( tag )
116
119
}
117
120
118
121
/**
Original file line number Diff line number Diff line change @@ -32,6 +32,16 @@ const tests = [
32
32
callback: $$v => {
33
33
a.b = $$v;
34
34
}
35
+ }} />;` ,
36
+ } ,
37
+ {
38
+ name : 'Kebab case component vModel' ,
39
+ from : `const A = <my-component vModel={a.b} />` ,
40
+ to : `const A = <my-component model={{
41
+ value: a.b,
42
+ callback: $$v => {
43
+ a.b = $$v;
44
+ }
35
45
}} />;` ,
36
46
} ,
37
47
{
Original file line number Diff line number Diff line change @@ -2413,6 +2413,11 @@ html-encoding-sniffer@^1.0.2:
2413
2413
dependencies :
2414
2414
whatwg-encoding "^1.0.1"
2415
2415
2416
+ html-tags@^2.0.0 :
2417
+ version "2.0.0"
2418
+ resolved "https://registry.yarnpkg.com/html-tags/-/html-tags-2.0.0.tgz#10b30a386085f43cede353cc8fa7cb0deeea668b"
2419
+ integrity sha1-ELMKOGCF9Dzt41PMj6fLDe7qZos=
2420
+
2416
2421
http-signature@~1.2.0 :
2417
2422
version "1.2.0"
2418
2423
resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-1.2.0.tgz#9aecd925114772f3d95b65a60abb8f7c18fbace1"
@@ -4407,6 +4412,11 @@ supports-color@^5.0.0, supports-color@^5.3.0:
4407
4412
dependencies :
4408
4413
has-flag "^3.0.0"
4409
4414
4415
+ svg-tags@^1.0.0 :
4416
+ version "1.0.0"
4417
+ resolved "https://registry.yarnpkg.com/svg-tags/-/svg-tags-1.0.0.tgz#58f71cee3bd519b59d4b2a843b6c7de64ac04764"
4418
+ integrity sha1-WPcc7jvVGbWdSyqEO2x95krAR2Q=
4419
+
4410
4420
symbol-observable@^0.2.2 :
4411
4421
version "0.2.4"
4412
4422
resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-0.2.4.tgz#95a83db26186d6af7e7a18dbd9760a2f86d08f40"
You can’t perform that action at this time.
0 commit comments