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

[css-selectors-4] New selector request [:ifchecked(input-id)] #678

Open
Somnium7 opened this issue Nov 3, 2016 · 2 comments
Open

[css-selectors-4] New selector request [:ifchecked(input-id)] #678

Somnium7 opened this issue Nov 3, 2016 · 2 comments

Comments

@Somnium7
Copy link

Somnium7 commented Nov 3, 2016

I am requesting a new selector in CSS4:
selector:ifchecked(input-id)
Which will match all elements by selector only if checkbox or radio button with id input-id is checked.

Motivation is following:
Consider code
<label for="abc">Test</label><input type="checkbox" id="abc">
where I need to emphasize label with bold when checkbox is selected. With CSS3 it is not possible. It will possible with CSS4 selector :has(#abc:checked) label[for="abc"]. However, :has selector will have perfomance problems (and because of that, possibly, will be never implemented). Requested selector will not have perfomance problems, because it behaves like normal selector, but with additional check whether corresponding checkbox/radio button is checked (which have average complexity O(1)).

@cvrebert
Copy link
Member

cvrebert commented Nov 3, 2016

One alternative to this would be #397.

@Somnium7
Copy link
Author

Somnium7 commented Nov 4, 2016

This is more general and more useful.

For example, if you have a tree structure of checkboxes, with this selector you style tree parent depending on children check state.

@fantasai fantasai added the selectors-4 Current Work label Mar 30, 2017
@fantasai fantasai added selectors-5 and removed selectors-4 Current Work labels Jan 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants