-
-
Notifications
You must be signed in to change notification settings - Fork 147
Allow :is() and :where() selectors #789
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
Open
KH-Coder865
wants to merge
16
commits into
jupyterlab:main
Choose a base branch
from
KH-Coder865:allow-is-where-selectors
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
a92102d
Allow :is() and :where() selectors in selector validation
KH-Coder865 7e3300c
Automatic application of license header
github-actions[bot] 8336e48
Updating tsconfig.json to resolve build
KH-Coder865 83383f5
Updating tsconfig.json to resolve build
KH-Coder865 15263f7
Applied Suggestive Changes
KH-Coder865 18d052e
Moved updated functionality to domutils
KH-Coder865 05b9aa3
Update packages/domutils/src/selector.ts
KH-Coder865 23cdd58
Finalized small changes
KH-Coder865 74b8138
Try to fix test
krassowski 1e38ea7
Remove second copy of selector test
krassowski effc878
Move the `Selector` tests under the `Selector` group
krassowski 4bce81f
Fix nesting of test cases
krassowski c01cfe5
Clarify error messages regarding selector commas
krassowski 40f1a68
Add test for commas inside nested :is() selector
krassowski c30db48
lint
krassowski 8635c88
Add another test
krassowski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,22 @@ | ||
| /* | ||
| * Copyright (c) Jupyter Development Team. | ||
| * Distributed under the terms of the Modified BSD License. | ||
| */ | ||
|
|
||
| /** | ||
| * Remove :is() and :where() functional pseudo-classes so that | ||
| * commas inside them do not count as top-level selector separators. | ||
| */ | ||
| export function stripIsWhere(selector: string): string { | ||
| return selector.replace( | ||
| /:(is|where)\(([^()]|\([^()]*\))*\)/g, | ||
| '' | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * Returns true if the selector contains a top-level comma. | ||
| */ | ||
| export function hasTopLevelComma(selector: string): boolean { | ||
| return stripIsWhere(selector).indexOf(',') !== -1; | ||
| } | ||
KH-Coder865 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
This file contains hidden or 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,25 @@ | ||
| /* | ||
| * Copyright (c) Jupyter Development Team. | ||
| * Distributed under the terms of the Modified BSD License. | ||
| */ | ||
|
|
||
| import { hasTopLevelComma } from '@lumino/coreutils/src/selector'; | ||
KH-Coder865 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| import { expect } from 'chai'; | ||
|
|
||
| describe('selector validation', () => { | ||
KH-Coder865 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| it('allows commas inside :is()', () => { | ||
| expect(hasTopLevelComma('.a:is(.b,.c)')).to.equal(false); | ||
| }); | ||
|
|
||
| it('allows commas inside :where()', () => { | ||
| expect(hasTopLevelComma('.a:where(.b,.c)')).to.equal(false); | ||
| }); | ||
|
|
||
| it('rejects top-level commas', () => { | ||
| expect(hasTopLevelComma('.a, .b')).to.equal(true); | ||
| }); | ||
|
|
||
| it('rejects mixed selectors', () => { | ||
| expect(hasTopLevelComma('.a:is(.b,.c), .d')).to.equal(true); | ||
| }); | ||
| }); | ||
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.