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

Modify :is() and :where() to support selecting derived node types #1037

Open
sirisian opened this issue Nov 19, 2023 · 0 comments
Open

Modify :is() and :where() to support selecting derived node types #1037

sirisian opened this issue Nov 19, 2023 · 0 comments

Comments

@sirisian
Copy link

I think this fits with Web Components as they deal with derived HTMLElements.

Right now when you want to refer to all inherited items you must use :is() and manually list the base class and derived items. When you want anyone to be able to extend things and have rules apply to their new component this is not ideal.

Alternatives (mentioned to me by @annevk) is to add a state in the base class element which is then set for all derived. While that works it seems arbitrary like adding an attribute or class.

The example I had in mind is I have a ui-treenode, ui-node (graph nodes), and others. My ui-node extends ui-treenode so it can just be dropped into trees or have child elements in certain cases. A lot of the CSS rules should apply to everything derived from ui-treenode, so one would just use :is(ui-treenode / all) ... in the web component CSS or in global CSS.

The syntax proposed :is(ui-treenode / all) where derived can be default (matches base only and is the default), all(matches base class and derived), or derived (matches derived only and not base class). (Feel free to use more standard names and change this syntax since I just made it up for this example). :where would support identical syntax.

My initial thinking was to have a separate syntax like is-a(), but then that could result in nesting inside of :is() which is verbose compared to just writing :is(ul, li, ui-button / all). So I think adding something :is() would be a minimal solution. Unsure if any other proposals are connected to that pseudo-class.

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

No branches or pull requests

1 participant