-
Notifications
You must be signed in to change notification settings - Fork 292
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix :where/:is in scoped selectors (#204)
- Loading branch information
1 parent
5833d4e
commit 16f77ef
Showing
5 changed files
with
117 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@vanilla-extract/css': patch | ||
--- | ||
|
||
Ensure `:where`/`:is` selectors are supported when validating scoped selectors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { validateSelector } from './validateSelector'; | ||
|
||
describe('validateSelector', () => { | ||
describe('valid selectors', () => { | ||
const validSelectors = [ | ||
'.target', | ||
'.target, .target', | ||
'.target:hover', | ||
'.target:hover:focus', | ||
'.target:where(:hover, :focus)', | ||
'.target:where(:hover, :focus), .target', | ||
'.target:is(:hover, :focus)', | ||
'.target:hover:focus:not(.a)', | ||
'.target:hover:focus:where(:not(.a, .b))', | ||
'.target:hover:focus:is(:not(.a, .b))', | ||
'.target.a', | ||
'.a.target', | ||
'.a.target.b', | ||
'.a.b.target', | ||
'.a .target', | ||
'.a .target:hover', | ||
'.a > .target', | ||
'.a ~ .target', | ||
'.a + .target', | ||
'.a > .b ~ .target', | ||
'.a > .b + .target:hover', | ||
'.a:where(.b, .c) > .target', | ||
'.a:is(.b, .c) > .target', | ||
'.target, .foo .target', | ||
]; | ||
|
||
validSelectors.forEach((selector) => | ||
it(selector, () => { | ||
expect(() => validateSelector(selector, 'target')).not.toThrow(); | ||
}), | ||
); | ||
}); | ||
|
||
describe('invalid selectors', () => { | ||
const invalidSelectors = [ | ||
'.a', | ||
'.target .a', | ||
'.target, .a', | ||
'.a, .target', | ||
'.target, .target, .a', | ||
'.a .target .b', | ||
'.target :hover', | ||
'.a .target :hover', | ||
'.target > .a', | ||
'.target + .a', | ||
'.target ~ .a', | ||
'.target:where(:hover, :focus) .a', | ||
]; | ||
|
||
invalidSelectors.forEach((selector) => | ||
it(selector, () => { | ||
expect(() => validateSelector(selector, 'target')).toThrow(); | ||
}), | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters