Skip to content

Commit c61b098

Browse files
authored
Fix @extend through mixed @import and @use (#2627)
Closes #2616
1 parent dc923ed commit c61b098

File tree

8 files changed

+28
-5
lines changed

8 files changed

+28
-5
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 1.91.1-dev
2+
3+
* Fix a bug where `@extend` rules loaded through a mixture of `@import` and
4+
`@use` rules could fail to apply correctly.
5+
16
## 1.91.0
27

38
* **Potentially breaking change:** `meta.inspect()` (as well as other systems

lib/src/extend/extension_store.dart

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1102,12 +1102,18 @@ class ExtensionStore {
11021102
var newMediaContexts = <ModifiableBox<SelectorList>, List<CssMediaQuery>>{};
11031103
var oldToNewSelectors = Map<SelectorList, Box<SelectorList>>.identity();
11041104

1105+
// A map from the old to the new selector boxes. This ensures that if a
1106+
// single box is referenced by multiple simple selectors, we only create a
1107+
// single new box for it in the cloned structure.
1108+
var newBoxes = <ModifiableBox<SelectorList>, ModifiableBox<SelectorList>>{};
1109+
11051110
_selectors.forEach((simple, selectors) {
11061111
var newSelectorSet = <ModifiableBox<SelectorList>>{};
11071112
newSelectors[simple] = newSelectorSet;
11081113

11091114
for (var selector in selectors) {
1110-
var newSelector = ModifiableBox(selector.value);
1115+
var newSelector =
1116+
newBoxes.putIfAbsent(selector, () => ModifiableBox(selector.value));
11111117
newSelectorSet.add(newSelector);
11121118
oldToNewSelectors[selector.value] = newSelector.seal();
11131119

lib/src/util/box.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ class Box<T> {
1616
bool operator ==(Object other) => other is Box<T> && other._inner == _inner;
1717

1818
int get hashCode => _inner.hashCode;
19+
20+
String toString() => "<box: $value>";
1921
}
2022

2123
/// A mutable reference to a (presumably immutable) value.
@@ -31,4 +33,6 @@ class ModifiableBox<T> {
3133
///
3234
/// The underlying modifiable box may still be modified.
3335
Box<T> seal() => Box._(this);
36+
37+
String toString() => "<modifiable box: $value>";
3438
}

pkg/sass-parser/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.4.27-dev
2+
3+
* No user-visible changes.
4+
15
## 0.4.26
26

37
* No user-visible changes.

pkg/sass-parser/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sass-parser",
3-
"version": "0.4.26",
3+
"version": "0.4.27-dev",
44
"description": "A PostCSS-compatible wrapper of the official Sass parser",
55
"repository": "sass/sass",
66
"author": "Google Inc.",

pkg/sass_api/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 15.9.1-dev
2+
3+
* No user-visible changes.
4+
15
## 15.9.0
26

37
* No user-visible changes.

pkg/sass_api/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ name: sass_api
22
# Note: Every time we add a new Sass AST node, we need to bump the *major*
33
# version because it's a breaking change for anyone who's implementing the
44
# visitor interface(s).
5-
version: 15.9.0
5+
version: 15.9.1-dev
66
description: Additional APIs for Dart Sass.
77
homepage: https://github.com/sass/dart-sass
88

99
environment:
1010
sdk: ">=3.6.0 <4.0.0"
1111

1212
dependencies:
13-
sass: 1.91.0
13+
sass: 1.91.1
1414

1515
dev_dependencies:
1616
dartdoc: ^8.0.14

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: sass
2-
version: 1.91.0
2+
version: 1.91.1-dev
33
description: A Sass implementation in Dart.
44
homepage: https://github.com/sass/dart-sass
55

0 commit comments

Comments
 (0)