Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix purgecss-from-pug not handle class attributes with multiple values correctly #677 #678

Merged
merged 1 commit into from May 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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