Skip to content

Commit 7ad1afe

Browse files
committed
Consider Multiline class attribute
1 parent ae332c1 commit 7ad1afe

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

src/parsers/template.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ const updateMultipleClasses = (processor: Processor, classNames: string): string
1212
const classes: string[] = classNames.split(' ');
1313
const generatedClassNames: string = classes.reduce((accumulator, currentValue, currentIndex) => {
1414
let value: string = currentValue;
15-
if (currentValue in processor.cssModuleList) {
16-
value = processor.cssModuleList[currentValue.trim()];
15+
const rawValue: string = value.trim();
16+
if (rawValue in processor.cssModuleList) {
17+
value = value.replace(rawValue, processor.cssModuleList[rawValue]);
1718
}
1819
if (currentIndex < classes.length - 1) {
1920
value += ' ';
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const compiler = require('../compiler.js');
2+
3+
test('Replace multiline class attribute', async () => {
4+
const output = await compiler({
5+
source: `<style module>.red { color: red; } .strong { font-weight: bold; }</style><span class="btn
6+
red
7+
strong
8+
main
9+
">btn</span>`,
10+
}, {
11+
localIdentName: '[local]-123',
12+
});
13+
14+
expect(output).toBe(
15+
`<style module>:global(.red-123) { color: red; } :global(.strong-123) { font-weight: bold; }</style><span class="btn
16+
red-123
17+
strong-123
18+
main
19+
">btn</span>`
20+
);
21+
});
22+

0 commit comments

Comments
 (0)