Skip to content

Commit

Permalink
fix: fixes #13, and add more cases (#14)
Browse files Browse the repository at this point in the history
* fix: fixes #13, and add more cases

* chore: update comment
  • Loading branch information
ygj6 authored Jun 23, 2021
1 parent 5953fd3 commit e584cba
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/operationUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export function removeRange(range: number[]): Operation {
* @returns {string} The text of the node
*/
export function getText(node: Node, source: string): string {
const start = node.range[0]
const end = node.range[1]
const start = node?.range[0]
const end = node?.range[1]
return source.slice(start, end)
}
2 changes: 1 addition & 1 deletion vue-transformations/__test__/v-bind-sync.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { runTest } from '../../src/testUtils'

runTest(
'Convert usage of slot-scope before vue 2.6',
'Replace .sync modifiers in v-bind with v-model',
'v-bind-sync',
'v-bind-sync',
'vue',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<template>
<div class="hello">
<ChildComponent :title.sync="pageTitle" />
<ChildComponent v-bind:propName.sync="foo" />
<ChildComponent v-bind:[dynamiArg].sync="foo" />
<ChildComponent :propName.sync="foo" />

<!-- incorrect usage, not transform -->
<ChildComponent v-bind.sync="foo" />
</div>
</template>
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<template>
<div class="hello">
<ChildComponent v-model:title="pageTitle" />
<ChildComponent v-model:propName="foo" />
<ChildComponent v-model:[dynamiArg]="foo" />
<ChildComponent v-model:propName="foo" />

<!-- incorrect usage, not transform -->
<ChildComponent v-bind.sync="foo" />
</div>
</template>
4 changes: 2 additions & 2 deletions vue-transformations/v-bind-sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ export const transformAST: VueASTTransformation = context => {

export default wrap(transformAST)
/**
* search slot attribute nodes
* search v-bind attribute nodes
*
* @param context
* @returns slot attribute nodes
* @returns v-bind attribute nodes
*/
function findNodes(context: any): Node[] {
const { file } = context
Expand Down

0 comments on commit e584cba

Please sign in to comment.