Skip to content

Commit 3399ce1

Browse files
committed
fix: closes #3
1 parent 6954d75 commit 3399ce1

8 files changed

+26
-8
lines changed

vue-transformations/__test__/v-bind-order-sensitive.spec.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,15 @@ import { runTest } from '../../src/testUtils'
33
runTest(
44
'Fix v-bind Merge Behavior',
55
'v-bind-order-sensitive',
6-
'v-bind-object',
6+
'v-bind-object-not-in-the-end',
7+
'vue',
8+
'vue'
9+
)
10+
11+
runTest(
12+
'Fix v-bind Merge Behavior',
13+
'v-bind-order-sensitive',
14+
'v-bind-object-in-the-end',
715
'vue',
816
'vue'
917
)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<template>
2+
<div id='red' v-bind="{id:'blue'}"></div>
3+
</template>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<template>
2+
<div v-bind="{id:'blue'}" id='red' ></div>
3+
</template>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<template>
2+
<div :id='id' class='orderArea orderBarArea'></div>
3+
</template>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<template>
2+
<div :id='id' class='orderArea orderBarArea'></div>
3+
</template>

vue-transformations/__testfixtures__/v-bind-order-sensitive/v-bind-object.input.vue

Lines changed: 0 additions & 3 deletions
This file was deleted.

vue-transformations/__testfixtures__/v-bind-order-sensitive/v-bind-object.output.vue

Lines changed: 0 additions & 3 deletions
This file was deleted.

vue-transformations/v-bind-order-sensitive.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ function fix(node: Node, source: string): Operation[] {
4444
// get parent node
4545
const target: any = node!.parent;
4646
// get the value of v-bind according to the range
47-
const bindValue:string = source.slice(node.range[0], node.range[1]) + ' ';
47+
let bindValue:string = source.slice(node.range[0], node.range[1]);
48+
49+
if (target.attributes[target.attributes.length -1] === node) {
50+
bindValue += ' ';
51+
}
4852
// remove node
4953
fixOperations.push(OperationUtils.remove(node));
5054
// add node to the first

0 commit comments

Comments
 (0)