Open krassowski opened 4 months ago
Selectors with comma are currently straight out rejected in a few places:
https://github.com/jupyterlab/lumino/blob/10d232e7d45572ed5fbb4389c3c9a4671ab0e5eb/packages/widgets/src/contextmenu.ts#L330-L333
https://github.com/jupyterlab/lumino/blob/10d232e7d45572ed5fbb4389c3c9a4671ab0e5eb/packages/commands/src/index.ts#L1561-L1566
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()
:where()
Lack of support for :is and :where makes creating selectors for certain commands and context menu more difficult than it should be in 2024.
:is
:where
Implement support for :is() and :where().
Encountered this in https://github.com/jupyterlab/jupyterlab/pull/15845 when trying to make the context menu show for .jp-RunningSessions-item:is(.jp-mod-kernel,.jp-mod-kernel-widget).
.jp-RunningSessions-item:is(.jp-mod-kernel,.jp-mod-kernel-widget)
Problem
Selectors with comma are currently straight out rejected in a few places:
https://github.com/jupyterlab/lumino/blob/10d232e7d45572ed5fbb4389c3c9a4671ab0e5eb/packages/widgets/src/contextmenu.ts#L330-L333
https://github.com/jupyterlab/lumino/blob/10d232e7d45572ed5fbb4389c3c9a4671ab0e5eb/packages/commands/src/index.ts#L1561-L1566
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 https://github.com/jupyterlab/jupyterlab/pull/15845 when trying to make the context menu show for
.jp-RunningSessions-item:is(.jp-mod-kernel,.jp-mod-kernel-widget)
.