diff --git a/CHANGELOG.md b/CHANGELOG.md index 22dd57531..60aab93c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. @@ -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. diff --git a/lib/src/extend/extension_store.dart b/lib/src/extend/extension_store.dart index c821a21c9..a95654957 100644 --- a/lib/src/extend/extension_store.dart +++ b/lib/src/extend/extension_store.dart @@ -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': diff --git a/lib/src/extend/functions.dart b/lib/src/extend/functions.dart index 1b8b34b61..45a704588 100644 --- a/lib/src/extend/functions.dart +++ b/lib/src/extend/functions.dart @@ -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]. @@ -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); diff --git a/lib/src/parse/selector.dart b/lib/src/parse/selector.dart index 78af93ca8..199189aaa 100644 --- a/lib/src/parse/selector.dart +++ b/lib/src/parse/selector.dart @@ -13,6 +13,7 @@ import 'parser.dart'; /// Pseudo-class selectors that take unadorned selectors as arguments. final _selectorPseudoClasses = { "not", + "is", "matches", "current", "any",