Skip to content

Commit e584cba

Browse files
authored
fix: fixes #13, and add more cases (#14)
* fix: fixes #13, and add more cases * chore: update comment
1 parent 5953fd3 commit e584cba

File tree

5 files changed

+17
-5
lines changed

5 files changed

+17
-5
lines changed

Diff for: src/operationUtils.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ export function removeRange(range: number[]): Operation {
136136
* @returns {string} The text of the node
137137
*/
138138
export function getText(node: Node, source: string): string {
139-
const start = node.range[0]
140-
const end = node.range[1]
139+
const start = node?.range[0]
140+
const end = node?.range[1]
141141
return source.slice(start, end)
142142
}

Diff for: vue-transformations/__test__/v-bind-sync.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { runTest } from '../../src/testUtils'
22

33
runTest(
4-
'Convert usage of slot-scope before vue 2.6',
4+
'Replace .sync modifiers in v-bind with v-model',
55
'v-bind-sync',
66
'v-bind-sync',
77
'vue',
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
<template>
22
<div class="hello">
33
<ChildComponent :title.sync="pageTitle" />
4+
<ChildComponent v-bind:propName.sync="foo" />
5+
<ChildComponent v-bind:[dynamiArg].sync="foo" />
6+
<ChildComponent :propName.sync="foo" />
7+
8+
<!-- incorrect usage, not transform -->
9+
<ChildComponent v-bind.sync="foo" />
410
</div>
511
</template>
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
<template>
22
<div class="hello">
33
<ChildComponent v-model:title="pageTitle" />
4+
<ChildComponent v-model:propName="foo" />
5+
<ChildComponent v-model:[dynamiArg]="foo" />
6+
<ChildComponent v-model:propName="foo" />
7+
8+
<!-- incorrect usage, not transform -->
9+
<ChildComponent v-bind.sync="foo" />
410
</div>
511
</template>

Diff for: vue-transformations/v-bind-sync.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ export const transformAST: VueASTTransformation = context => {
1818

1919
export default wrap(transformAST)
2020
/**
21-
* search slot attribute nodes
21+
* search v-bind attribute nodes
2222
*
2323
* @param context
24-
* @returns slot attribute nodes
24+
* @returns v-bind attribute nodes
2525
*/
2626
function findNodes(context: any): Node[] {
2727
const { file } = context

0 commit comments

Comments
 (0)