diff --git a/src/constants.ts b/src/constants.ts index 00a71a1..5cee7d2 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -4,7 +4,7 @@ export const PARAM_KEY = "pseudo" // Pseudo-elements which are not allowed to have classes applied on them // E.g. ::-webkit-scrollbar-thumb.pseudo-hover is not a valid selector -export const EXCLUDED_PSEUDO_ELEMENTS = ["::-webkit-scrollbar-thumb"] +export const EXCLUDED_PSEUDO_ELEMENTS = ["::-webkit-scrollbar-thumb", "::-webkit-slider-thumb"] // Dynamic pseudo-classes // @see https://www.w3.org/TR/2018/REC-selectors-3-20181106/#dynamic-pseudos diff --git a/src/preview/rewriteStyleSheet.test.ts b/src/preview/rewriteStyleSheet.test.ts index 6ab1d75..8fb32b7 100644 --- a/src/preview/rewriteStyleSheet.test.ts +++ b/src/preview/rewriteStyleSheet.test.ts @@ -51,6 +51,12 @@ describe("rewriteStyleSheet", () => { expect(sheet.cssRules[0].selectorText).not.toContain("::-webkit-scrollbar-thumb.pseudo-hover") }) + it("does not add .pseudo- to pseudo-class, which does not support classes", () => { + const sheet = new Sheet("::-webkit-slider-thumb:hover { border-color: transparent; }") + rewriteStyleSheet(sheet as any) + expect(sheet.cssRules[0].selectorText).not.toContain("::-webkit-slider-thumb.pseudo-hover") + }) + it("adds alternative selector for each pseudo selector", () => { const sheet = new Sheet("a:hover, a:focus { color: red }") rewriteStyleSheet(sheet as any)