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

Make :is() behave like :matches() #1315

Merged
merged 3 commits into from May 20, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -15,6 +15,10 @@
made slash-free in both cases. This is a behavioral change, but it's unlikely
to affect any real-world stylesheets.

* [`:is()`][] now behaves identically to `:matches()`.

[`:is()`]: https://developer.mozilla.org/en-US/docs/Web/CSS/:is
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a good idea to put this at the root level rather than indented to match the bullet point; although it should work either way, some Markdown processors choke on indented references.


### JS API

* The `this` context for importers now has a `fromImport` field, which is `true`
Expand Down
6 changes: 5 additions & 1 deletion lib/src/extend/extension_store.dart
Expand Up @@ -818,9 +818,13 @@ class ExtensionStore {
// become `.foo:not(.bar)`. However, this is a narrow edge case and
// supporting it properly would make this code and the code calling it
// a lot more complicated, so it's not supported for now.
if (innerPseudo.normalizedName != 'matches') return [];
if (innerPseudo.normalizedName != 'is' &&
innerPseudo.normalizedName != 'matches') {
return [];
}
return innerSelector.components;

case 'is':
case 'matches':
case 'any':
case 'current':
Expand Down
9 changes: 8 additions & 1 deletion lib/src/extend/functions.dart
Expand Up @@ -21,7 +21,13 @@ import '../utils.dart';
/// subselectors of their arguments.
///
/// For example, `.foo` is a superselector of `:matches(.foo)`.
final _subselectorPseudos = {'matches', 'any', 'nth-child', 'nth-last-child'};
final _subselectorPseudos = {
'is',
'matches',
'any',
'nth-child',
'nth-last-child'
};

/// Returns the contents of a [SelectorList] that matches only elements that are
/// matched by both [complex1] and [complex2].
Expand Down Expand Up @@ -734,6 +740,7 @@ bool _selectorPseudoIsSuperselector(
var selector1 = selector1_; // dart-lang/sdk#45348

switch (pseudo1.normalizedName) {
case 'is':
case 'matches':
case 'any':
var selectors = _selectorPseudoArgs(compound2, pseudo1.name);
Expand Down
1 change: 1 addition & 0 deletions lib/src/parse/selector.dart
Expand Up @@ -13,6 +13,7 @@ import 'parser.dart';
/// Pseudo-class selectors that take unadorned selectors as arguments.
final _selectorPseudoClasses = {
"not",
"is",
"matches",
"current",
"any",
Expand Down