Skip to content

Commit 244380b

Browse files
authored
Handle v-slot expression correctly (#181)
1 parent 5a4a64e commit 244380b

4 files changed

Lines changed: 29 additions & 1 deletion

File tree

src/utils/vue.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export function isVueEventBinding(name: string): boolean {
5050
* @returns `true` if `name` passes the vue expression check, otherwise `false`.
5151
*/
5252
export function isVueExpression(name: string): boolean {
53-
return /^((v-(bind|slot))?:|v-(model|if|for|else-if|text|html)).*/.test(name);
53+
return /^((v-(bind|slot))?:|v-(model|slot|if|for|else-if|text|html)).*/.test(name);
5454
}
5555

5656
/**
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
v-slide-group(v-model="model")
2+
v-slide-item(v-slot="{ active, toggle }")
3+
v-card
4+
//- ...
5+
v-slide-item(v-slot="{ active, toggle }")
6+
v-card
7+
//- ...
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { readFileSync } from 'fs';
2+
import { resolve } from 'path';
3+
import { format } from 'prettier';
4+
import { plugin } from './../../../src/index';
5+
6+
describe('Issues', () => {
7+
test('should handle v-slot expression', () => {
8+
const expected: string = readFileSync(resolve(__dirname, 'formatted.pug'), 'utf8');
9+
const code: string = readFileSync(resolve(__dirname, 'unformatted.pug'), 'utf8');
10+
const actual: string = format(code, { parser: 'pug', plugins: [plugin] });
11+
12+
expect(actual).toBe(expected);
13+
});
14+
});
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
v-slide-group(v-model="model")
2+
v-slide-item(v-slot="{ active , toggle }")
3+
v-card
4+
//- ...
5+
v-slide-item(v-slot="{ active, toggle }")
6+
v-card
7+
//- ...

0 commit comments

Comments
 (0)