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

:is() & :where() use cases #272

Open
ffoodd opened this issue Jul 13, 2017 · 6 comments
Open

:is() & :where() use cases #272

ffoodd opened this issue Jul 13, 2017 · 6 comments
Assignees

Comments

@ffoodd
Copy link
Owner

ffoodd commented Jul 13, 2017

Looks familiar, isn't it? Formerly known as :any(), it came back from outterspace as :matches().

And it starts to be pretty well supported.

@ffoodd ffoodd self-assigned this Jul 13, 2017
@ffoodd
Copy link
Owner Author

ffoodd commented Oct 9, 2017

Be careful with specitify and -*-:any()'s old versions: there's a dedicated issue in AutoPrefixer.

@ffoodd ffoodd added this to the 5.0 milestone Nov 22, 2017
@ffoodd
Copy link
Owner Author

ffoodd commented Nov 29, 2017

FWIW, current W3C draft specification.

@ffoodd ffoodd removed this from the 5.0 milestone Dec 15, 2017
@ffoodd
Copy link
Owner Author

ffoodd commented Dec 15, 2017

For now on, I can't think about a test that wouldn't be writable without :matches(), so for an extended browser support we won't use this until it's fully supported on major browsers stable releases.

However I already found some tests which would be shorter with it. Be careful with this, since ending a selector with a :matches() pseudo-class is not good for performances.

Errors

Nested interactive elements

:matches(a, button) :matches(a[href], audio[controls], video[controls], button, details, embed, iframe, img[usemap], label, select, textarea, input[type]:not([hidden]))

[width] & [height] attributes

:not(:matches(img, object, embed, svg, canvas)):matches([width], [height])

Table used for layout

table[role="presentation"] :matches(th, thead, tfoot, caption, colgroup, [axis], [scope], [headers])

Button not submitting

button:matches([type="reset"], [type="button"]):matches([formmethod], [formaction], [formtarget],[formenctype], [formnovalidate])

Missing a value

input:matches([type="reset"], [type="button"]], [type="submit"]):not([value]):not([title]):not([aria-label]):not([aria-labelledby])

Missing source for img

:matches(img, input[type="image"]):not([src]):not([srcset]),
:matches(img, input[type="image"]):matches([src=""], [src=" "], [src="#"], [src="/"]),
:matches(img, input[type="image"]):matches([srcset=""], [srcset=" "], [srcset="#"], [srcset="/"])

Missing alternative for img

:matches(img, area, input[type="image"]):not([alt]),
:matches(img, area, input[type="image"]):matches([alt=" "])

Warnings

Invalid nesting in a list

:not(ul):not(ol) > li,
:matches(ul, ol) > :not(li)

The same for defintion list, obvisouly.

Misplaced div

:matches(b, i, q, em, abbr, cite, code, span, small, label, strong) div

[alt] containing file name

:matches(img, area, input[type="image"], embed[type="image"], object[type="image"]):matches([alt$=".pdf"], [alt$=".doc"], [alt$=".png"], [alt$=".jpg"], [alt$=".gif"]

Note: I shortened filename list :)

I won't do all of them but it would be pretty easy :)

@ffoodd ffoodd changed the title :matches() use cases? :matches() use cases Sep 12, 2018
@ffoodd
Copy link
Owner Author

ffoodd commented Oct 29, 2018

According to the MDN browser compatibility table, I think we gotta go :)

@ffoodd
Copy link
Owner Author

ffoodd commented Feb 12, 2019

Uh oh, :matches() has been renamed as :is()w3c/csswg-drafts#3258

@ffoodd ffoodd changed the title :matches() use cases :is() use cases Jul 6, 2020
@ffoodd ffoodd changed the title :is() use cases :is() & :where() use cases Jan 27, 2022
@ffoodd
Copy link
Owner Author

ffoodd commented Jan 27, 2022

:where() can also help a lot, at least to lower specificity in some cases. Read Manuel Matuzovic's "Here’s what I didn’t know about :where()".

@ffoodd ffoodd moved this to To do in New tests Apr 26, 2023
@ffoodd ffoodd added this to New tests Apr 26, 2023
@ffoodd ffoodd moved this to To do in CSS modernisation Apr 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: To do
Status: To do
Development

No branches or pull requests

1 participant