mirror of
https://github.com/danog/dart-sass.git
synced 2025-01-23 06:12:00 +01:00
Properly register pseudos' child selectors in ExtensionStore (#1374)
Closes #1297
This commit is contained in:
parent
3918aefdfd
commit
713b7cc31e
@ -13,6 +13,9 @@
|
||||
URLs (those that begin with `/`) in `@import` rules would be passed to
|
||||
both Dart and JS importers as `file:` URLs.
|
||||
|
||||
* Fix an edge case where `@extend` wouldn't affect a selector within a
|
||||
pseudo-selector such as `:is()` that itself extended other selectors.
|
||||
|
||||
## 1.35.1
|
||||
|
||||
* Fix a bug where the quiet dependency flag didn't silence warnings in some
|
||||
|
@ -258,16 +258,12 @@ class ExtensionStore {
|
||||
|
||||
sources[complex] = extension;
|
||||
|
||||
for (var component in complex.components) {
|
||||
if (component is CompoundSelector) {
|
||||
for (var simple in component.components) {
|
||||
_extensionsByExtender.putIfAbsent(simple, () => []).add(extension);
|
||||
// Only source specificity for the original selector is relevant.
|
||||
// Selectors generated by `@extend` don't get new specificity.
|
||||
_sourceSpecificity.putIfAbsent(
|
||||
simple, () => complex.maxSpecificity);
|
||||
}
|
||||
}
|
||||
for (var simple in _simpleSelectors(complex)) {
|
||||
_extensionsByExtender.putIfAbsent(simple, () => []).add(extension);
|
||||
// Only source specificity for the original selector is relevant.
|
||||
// Selectors generated by `@extend` don't get new specificity.
|
||||
_sourceSpecificity.putIfAbsent(
|
||||
simple, () => complex.maxSpecificity);
|
||||
}
|
||||
|
||||
if (selectors != null || existingExtensions != null) {
|
||||
@ -292,6 +288,24 @@ class ExtensionStore {
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns an iterable of all simple selectors in [complex]
|
||||
Iterable<SimpleSelector> _simpleSelectors(ComplexSelector complex) sync* {
|
||||
for (var component in complex.components) {
|
||||
if (component is CompoundSelector) {
|
||||
for (var simple in component.components) {
|
||||
yield simple;
|
||||
|
||||
if (simple is! PseudoSelector) continue;
|
||||
var selector = simple.selector;
|
||||
if (selector == null) continue;
|
||||
for (var complex in selector.components) {
|
||||
yield* _simpleSelectors(complex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Extend [extensions] using [newExtensions].
|
||||
///
|
||||
/// Note that this does duplicate some work done by
|
||||
|
Loading…
x
Reference in New Issue
Block a user