Skip to content

Commit 6bf2168

Browse files
author
Michael Vurchio
committed
Fix shorthand directive
1 parent 938194c commit 6bf2168

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

src/parsers/template.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export default (processor: Processor): void => {
7878
if (name in processor.cssModuleList) {
7979
const start = item.start + directiveLength;
8080
const end = start + item.name.length;
81-
if (item.expression.type === 'Identifier') {
81+
if (item.expression.type === 'Identifier' && item.name === item.expression.name) {
8282
processor.magicContent.overwrite(
8383
start,
8484
end,

test/scopedFixtures/stylesAttribute.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ describe('Scoped Mode', () => {
5151

5252
test('Replace short hand directive', async () => {
5353
const output = await compiler({
54-
source: '<script>const red = true;</script><style module="scoped">.red { color: red; }</style><span class:red>Red</span>'
54+
source: '<script>const red = true;</script><style module="scoped">.red { color: red; } .blue { color: blue; }</style><span class:red class:blue={red}>Red</span>'
5555
}, {
5656
localIdentName: '[local]-123',
5757
});
58-
expect(output).toBe('<script>const red = true;</script><style module="scoped">.red-123 { color: red; }</style><span class:red-123={red}>Red</span>');
58+
expect(output).toBe('<script>const red = true;</script><style module="scoped">.red-123 { color: red; } .blue-123 { color: blue; }</style><span class:red-123={red} class:blue-123={red}>Red</span>');
5959
});
6060

6161
test('Replace Multiple Clasnames on attribute', async () => {

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
],
99
"noImplicitAny": true,
1010
"moduleResolution": "node",
11+
"removeComments": true,
1112
"sourceMap": false,
1213
"declaration": true,
1314
"outDir": "dist",

0 commit comments

Comments
 (0)