Skip to content

Commit

Permalink
Fix issue where existing non-class declarations are removed
Browse files Browse the repository at this point in the history
  • Loading branch information
winston0410 committed Aug 21, 2021
1 parent 3746677 commit ae7e85c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
2 changes: 0 additions & 2 deletions src/tokenizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ const hydrateClassCache = (
tempCache[className],
tokenizeRules(rule, declarationCache, next, mediaQueryName)
);
} else {
// TODO: handle other selector
}
};

Expand Down
6 changes: 4 additions & 2 deletions src/transformer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import MagicString from "magic-string";
import { walk } from "svelte/compiler";
import { assembleRules } from "./helper.js";
import { assembleRules, getClassName } from "./helper.js";

export default function (code, { dir, base }) {
const changeable = new MagicString(code);
Expand All @@ -17,7 +17,9 @@ export default function (code, { dir, base }) {
case "Style": {
for (const child of node.children) {
if (child.type === "Rule") {
changeable.overwrite(child.start, child.end, "");
if (getClassName(child)[0]) {
changeable.overwrite(child.start, child.end, "");
}
}
}
if (node.children.length > 0) {
Expand Down
2 changes: 0 additions & 2 deletions test/tokenizer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,4 @@ describe("when given a rule that uses id as selector", function () {
})
);
});

it("should be stored in replicate cache", async () => {});
});

0 comments on commit ae7e85c

Please sign in to comment.