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

Escape selectors containing forward slashes #816

Merged
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 src/core/lib/util/sassifySelector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ const sassifySelectorTasks: SassifySelectorTasks = [
// Fix the spotty `:root` support in emotion/styled-components
(selector): string => selector.replace(SELECTOR_ROOT, '*:root'),

// Escape selectors containing forward slashes, eg: group-hover/link:bg-black
(selector): string => selector.replace(/\//g, '\\/'),

(selector): string => selector.trim(),
]

Expand Down
44 changes: 22 additions & 22 deletions tests/arbitraryVariants.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,12 +335,12 @@ it('should support aria variants', async () => {
}
});
({
'.group/foo[aria-checked="true"] &': {
'.group\\\\/foo[aria-checked="true"] &': {
"textDecorationLine": "underline"
}
});
({
'.peer/foo[aria-checked="true"] ~ &': {
'.peer\\\\/foo[aria-checked="true"] ~ &': {
"textDecorationLine": "underline"
}
});
Expand All @@ -365,12 +365,12 @@ it('should support aria variants', async () => {
}
});
({
".group/foo[aria-sort=ascending] &": {
".group\\\\/foo[aria-sort=ascending] &": {
"textDecorationLine": "underline"
}
});
({
".peer/foo[aria-sort=ascending] ~ &": {
".peer\\\\/foo[aria-sort=ascending] ~ &": {
"textDecorationLine": "underline"
}
});
Expand Down Expand Up @@ -425,12 +425,12 @@ it('should support data variants', async () => {
}
});
({
'.group/foo[data-ui~="checked"] &': {
'.group\\\\/foo[data-ui~="checked"] &': {
"textDecorationLine": "underline"
}
});
({
'.peer/foo[data-ui~="checked"] ~ &': {
'.peer\\\\/foo[data-ui~="checked"] ~ &': {
"textDecorationLine": "underline"
}
});
Expand All @@ -455,12 +455,12 @@ it('should support data variants', async () => {
}
});
({
".group/foo[data-position=top] &": {
".group\\\\/foo[data-position=top] &": {
"textDecorationLine": "underline"
}
});
({
".peer/foo[data-position=top] ~ &": {
".peer\\\\/foo[data-position=top] ~ &": {
"textDecorationLine": "underline"
}
});
Expand Down Expand Up @@ -602,37 +602,37 @@ it('should be possible to use modifiers and arbitrary groups', async () => {
}
});
({
".group/foo:hover &": {
".group\\\\/foo:hover &": {
"textDecorationLine": "underline"
}
});
({
".group/foo:focus &": {
".group\\\\/foo:focus &": {
"textDecorationLine": "underline"
}
});
({
".group/foo:hover &": {
".group\\\\/foo:hover &": {
"textDecorationLine": "underline"
}
});
({
".group/foo[data-open] &": {
".group\\\\/foo[data-open] &": {
"textDecorationLine": "underline"
}
});
({
".group/foo[data-open] &": {
".group\\\\/foo[data-open] &": {
"textDecorationLine": "underline"
}
});
({
".in-foo .group/foo &": {
".in-foo .group\\\\/foo &": {
"textDecorationLine": "underline"
}
});
({
".group/foo.in-foo &": {
".group\\\\/foo.in-foo &": {
"textDecorationLine": "underline"
}
});
Expand Down Expand Up @@ -707,37 +707,37 @@ it('should be possible to use modifiers and arbitrary peers', async () => {
}
});
({
".peer/foo:hover ~ &": {
".peer\\\\/foo:hover ~ &": {
"textDecorationLine": "underline"
}
});
({
".peer/foo:focus ~ &": {
".peer\\\\/foo:focus ~ &": {
"textDecorationLine": "underline"
}
});
({
".peer/foo:hover ~ &": {
".peer\\\\/foo:hover ~ &": {
"textDecorationLine": "underline"
}
});
({
".peer/foo[data-open] ~ &": {
".peer\\\\/foo[data-open] ~ &": {
"textDecorationLine": "underline"
}
});
({
".peer/foo[data-open] ~ &": {
".peer\\\\/foo[data-open] ~ &": {
"textDecorationLine": "underline"
}
});
({
".in-foo .peer/foo ~ &": {
".in-foo .peer\\\\/foo ~ &": {
"textDecorationLine": "underline"
}
});
({
".peer/foo.in-foo ~ &": {
".peer\\\\/foo.in-foo ~ &": {
"textDecorationLine": "underline"
}
});
Expand Down