Skip to content

Commit 7c96030

Browse files
committed
Merge branch 'hotfix/2.1.2'
2 parents ae332c1 + bdd3937 commit 7c96030

File tree

4 files changed

+30
-3
lines changed

4 files changed

+30
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Svelte preprocess CSS Modules, changelog
22

3+
## 2.1.2 (Jan 8, 2021)
4+
5+
- Fix multiline class attribute [issue 39](https://github.com/micantoine/svelte-preprocess-cssmodules/issues/39)
6+
37
## 2.1.1 (Oct 27, 2021)
48

59
- Fix readme

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "svelte-preprocess-cssmodules",
3-
"version": "2.1.1",
3+
"version": "2.1.2",
44
"description": "Svelte preprocessor to generate CSS Modules classname on Svelte components",
55
"keywords": [
66
"svelte",

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 += ' ';

test/globalFixtures/template.test.js

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)