File tree Expand file tree Collapse file tree 2 files changed +15
-10
lines changed Expand file tree Collapse file tree 2 files changed +15
-10
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ defineInlineTest(
77 { } ,
88 `export default {
99 props: {
10+ title: String,
1011 value: String
1112 },
1213 model: {
@@ -22,7 +23,8 @@ defineInlineTest(
2223}` ,
2324 `export default {
2425 props: {
25- modelValue: String
26+ modelValue: String,
27+ value: String
2628 },
2729
2830 emits: ['update:modelValue'],
@@ -46,7 +48,8 @@ defineInlineTest(
4648 { } ,
4749 `export default {
4850 props: {
49- value: String
51+ value: String,
52+ title: String
5053 },
5154 model: {
5255 prop: 'title',
@@ -56,6 +59,7 @@ defineInlineTest(
5659}` ,
5760 `export default {
5861 props: {
62+ value: String,
5963 modelValue: String
6064 },
6165 emits: ['update:modelValue'],
@@ -73,7 +77,7 @@ defineInlineTest(
7377 { } ,
7478 `export default {
7579 props: {
76- value : String
80+ title : String
7781 },
7882 model: {
7983 prop: 'title',
Original file line number Diff line number Diff line change @@ -35,18 +35,19 @@ export const transformAST: ASTTransformation = ({ j, root }) => {
3535 if ( ! propsCollections . length ) return
3636
3737 // find the value which is in props
38- const valueNode : ObjectProperty = propsCollections
39- . find ( j . ObjectProperty , node => node . key . name === 'value' )
38+ const valueNodePath = propsCollections
39+ . find ( j . ObjectProperty , node => node . key . name === propName )
4040 . filter ( path => path . parent . parent . node . key . name === 'props' )
41- . get ( 0 ) . node
42-
43- // replace the value with modelValue
44- // @ts -ignore
45- valueNode ?. key . name = 'modelValue'
4641
4742 // remove model option
4843 modelCollection . remove ( )
4944
45+ if ( ! valueNodePath . length ) return
46+
47+ // replace the value with modelValue
48+ // @ts -ignore
49+ valueNodePath . get ( 0 ) . node . key . name = 'modelValue'
50+
5051 // find the methods option
5152 const methodsCollections = root
5253 . find ( j . ObjectProperty , node => node . key . name === 'methods' )
You can’t perform that action at this time.
0 commit comments