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 all commits
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
6 changes: 5 additions & 1 deletion CHANGELOG.md
Expand Up @@ -3,7 +3,7 @@
* Deprecate the use of `/` for division. The new `math.div()` function should be
used instead. See [this page][] for details.

[this page]: https://sass-lang.com/documentation/breaking-changes/slash-div
[this page]: https://sass-lang.com/documentation/breaking-changes/slash-div

* Add a `list.slash()` function that returns a slash-separated list.

Expand All @@ -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

* Fix a bug where non-integer numbers that were very close to integer
values would be incorrectly formatted in CSS.

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