5
5
// DO NOT EDIT. This file was generated from async_evaluate.dart.
6
6
// See tool/grind/synchronize.dart for details.
7
7
//
8
- // Checksum: a3068d04660dd2bed34b884aa6e1a21d423dc4e5
8
+ // Checksum: 25e98f7f4a04108e924c63b63b1db844637a66e0
9
9
//
10
10
// ignore_for_file: unused_import
11
11
@@ -216,6 +216,9 @@ final class _EvaluateVisitor
216
216
217
217
ModifiableCssParentNode ? __parent;
218
218
219
+ /// The original parent node for a stylesheet that was loaded with @import.
220
+ ModifiableCssParentNode ? _importParent;
221
+
219
222
/// The name of the current declaration parent.
220
223
String ? _declarationName;
221
224
@@ -1329,7 +1332,12 @@ final class _EvaluateVisitor
1329
1332
}
1330
1333
1331
1334
Value ? visitDeclaration (Declaration node) {
1332
- if (_styleRule == null && ! _inUnknownAtRule && ! _inKeyframes) {
1335
+ // If a stylesheet is @imported inside a style rule, declarations from that
1336
+ // imported sheet are parented by the outer style rule.
1337
+ var parent = _parent.parent == null ? _importParent : _parent;
1338
+
1339
+ if ((_styleRule == null && ! _inUnknownAtRule && ! _inKeyframes) ||
1340
+ parent == null ) {
1333
1341
throw _exception (
1334
1342
"Declarations may only be used within style rules." ,
1335
1343
node.span,
@@ -1342,14 +1350,14 @@ final class _EvaluateVisitor
1342
1350
);
1343
1351
}
1344
1352
1345
- var siblings = _parent .parent! .children;
1353
+ var siblings = parent .parent? .children ?? [] ;
1346
1354
var interleavedRules = < CssStyleRule > [];
1347
- if (siblings.last != _parent &&
1348
- // Reproduce this condition from [_warn] so that we don't add anything to
1349
- // [interleavedRules] for declarations in dependencies.
1355
+ if (siblings.last != parent &&
1356
+ // Reproduce this condition from [_warn] so that we don't add anything
1357
+ // to [interleavedRules] for declarations in dependencies.
1350
1358
! (_quietDeps && _inDependency)) {
1351
1359
loop:
1352
- for (var sibling in siblings.skip (siblings.indexOf (_parent ) + 1 )) {
1360
+ for (var sibling in siblings.skip (siblings.indexOf (parent ) + 1 )) {
1353
1361
switch (sibling) {
1354
1362
case CssComment ():
1355
1363
continue loop;
@@ -1395,7 +1403,7 @@ final class _EvaluateVisitor
1395
1403
_isEmptyList (value) ||
1396
1404
// Custom properties are allowed to have empty values, per spec.
1397
1405
name.value.startsWith ('--' )) {
1398
- _parent .addChild (
1406
+ parent .addChild (
1399
1407
ModifiableCssDeclaration (
1400
1408
name,
1401
1409
CssValue (value, expression.span),
@@ -1903,6 +1911,7 @@ final class _EvaluateVisitor
1903
1911
_stylesheet = stylesheet;
1904
1912
if (loadsUserDefinedModules) {
1905
1913
_root = ModifiableCssStylesheet (stylesheet.span);
1914
+ _importParent = _parent;
1906
1915
_parent = _root;
1907
1916
_endOfImports = 0 ;
1908
1917
_outOfOrderImports = null ;
@@ -1923,6 +1932,7 @@ final class _EvaluateVisitor
1923
1932
if (loadsUserDefinedModules) {
1924
1933
_root = oldRoot;
1925
1934
_parent = oldParent;
1935
+ _importParent = null ;
1926
1936
_endOfImports = oldEndOfImports;
1927
1937
_outOfOrderImports = oldOutOfOrderImports;
1928
1938
}
0 commit comments