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

Support the selectors with :is() and :where() #685

Open
krassowski opened this issue Feb 23, 2024 · 0 comments
Open

Support the selectors with :is() and :where() #685

krassowski opened this issue Feb 23, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@krassowski
Copy link
Member

Problem

Selectors with comma are currently straight out rejected in a few places:

function validateSelector(selector: string): string {
if (selector.indexOf(',') !== -1) {
throw new Error(`Selector cannot contain commas: ${selector}`);
}

function validateSelector(
options: CommandRegistry.IKeyBindingOptions
): string {
if (options.selector.indexOf(',') !== -1) {
throw new Error(`Selector cannot contain commas: ${options.selector}`);
}

This is understandable because the selector specificity can be only computed for individual selector, not a comma-separated list of selectors.

However, the :is() and :where() selectors now widely supported by browsers and take a comma-separated lists of selectors:

  • :is() counts towards specificity with the specificity of the most specific element on the list
  • :where() counts with specificity of zero (so very easy to implement!)

Lack of support for :is and :where makes creating selectors for certain commands and context menu more difficult than it should be in 2024.

Proposed Solution

Implement support for :is() and :where().

Additional context

Encountered this in jupyterlab/jupyterlab#15845 when trying to make the context menu show for .jp-RunningSessions-item:is(.jp-mod-kernel,.jp-mod-kernel-widget).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant