Skip to content

Commit ba6285d

Browse files
authored
fix(purgecss-from-pug): class attribute with multiple values not correctly handled with pug (#678)
fix issue #677
1 parent b51ad84 commit ba6285d

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

packages/purgecss-from-pug/__tests__/data.ts

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ html
66
div(class="test-container") Well
77
div(class="test-footer" id="an-id") I see a div
88
a(class="a-link" id="a-link" href="#") and a link
9+
div(class="first-class second-class") This div has two classes
910
input#blo.enabled(type="text" disabled)
1011
`;
1112

@@ -23,6 +24,8 @@ export const TEST_1_CLASS = [
2324
"test-container",
2425
"test-footer",
2526
"a-link",
27+
"first-class",
28+
"second-class",
2629
"enabled",
2730
];
2831

packages/purgecss-from-pug/src/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ const purgeFromPug = (content: string): string[] => {
88
case "tag":
99
case "id":
1010
case "class":
11-
selectors.push(token.val);
11+
selectors.push(...token.val.split(" "));
1212
break;
1313
case "attribute":
1414
if (token.name === "class" || token.name === "id") {
1515
selectors.push(
16-
token.mustEscape ? token.val.replace(/"/g, "") : token.val
16+
...(token.mustEscape ? token.val.replace(/"/g, "") : token.val).split(" ")
1717
);
1818
}
1919
break;

0 commit comments

Comments
 (0)