Skip to content

Commit

Permalink
fix(purgecss-from-pug): class attribute with multiple values not corr…
Browse files Browse the repository at this point in the history
…ectly handled with pug (#678)

fix issue #677
  • Loading branch information
Nauja committed May 31, 2021
1 parent b51ad84 commit ba6285d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions packages/purgecss-from-pug/__tests__/data.ts
Expand Up @@ -6,6 +6,7 @@ html
div(class="test-container") Well
div(class="test-footer" id="an-id") I see a div
a(class="a-link" id="a-link" href="#") and a link
div(class="first-class second-class") This div has two classes
input#blo.enabled(type="text" disabled)
`;

Expand All @@ -23,6 +24,8 @@ export const TEST_1_CLASS = [
"test-container",
"test-footer",
"a-link",
"first-class",
"second-class",
"enabled",
];

Expand Down
4 changes: 2 additions & 2 deletions packages/purgecss-from-pug/src/index.ts
Expand Up @@ -8,12 +8,12 @@ const purgeFromPug = (content: string): string[] => {
case "tag":
case "id":
case "class":
selectors.push(token.val);
selectors.push(...token.val.split(" "));
break;
case "attribute":
if (token.name === "class" || token.name === "id") {
selectors.push(
token.mustEscape ? token.val.replace(/"/g, "") : token.val
...(token.mustEscape ? token.val.replace(/"/g, "") : token.val).split(" ")
);
}
break;
Expand Down

0 comments on commit ba6285d

Please sign in to comment.