Skip to content

Commit f145e1c

Browse files
authored
Throw errors for misplaced statements in keyframe blocks (#2226)
1 parent eafc279 commit f145e1c

File tree

6 files changed

+54
-4
lines changed

6 files changed

+54
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.75.1
2+
3+
* Throw errors for misplaced statements in keyframe blocks.
4+
15
## 1.75.0
26

37
* Fix a bug in which stylesheet canonicalization could be cached incorrectly

lib/src/visitor/async_evaluate.dart

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,6 +1324,9 @@ final class _EvaluateVisitor
13241324
if (_declarationName != null) {
13251325
throw _exception(
13261326
"At-rules may not be used within nested declarations.", node.span);
1327+
} else if (_inKeyframes && _parent is CssKeyframeBlock) {
1328+
throw _exception(
1329+
"At-rules may not be used within keyframe blocks.", node.span);
13271330
}
13281331

13291332
var name = await _interpolationToValue(node.name);
@@ -1895,6 +1898,9 @@ final class _EvaluateVisitor
18951898
if (_declarationName != null) {
18961899
throw _exception(
18971900
"Media rules may not be used within nested declarations.", node.span);
1901+
} else if (_inKeyframes && _parent is CssKeyframeBlock) {
1902+
throw _exception(
1903+
"At-rules may not be used within keyframe blocks.", node.span);
18981904
}
18991905

19001906
var queries = await _visitMediaQueries(node.query);
@@ -1985,6 +1991,9 @@ final class _EvaluateVisitor
19851991
if (_declarationName != null) {
19861992
throw _exception(
19871993
"Style rules may not be used within nested declarations.", node.span);
1994+
} else if (_inKeyframes && _parent is CssKeyframeBlock) {
1995+
throw _exception(
1996+
"Style rules may not be used within keyframe blocks.", node.span);
19881997
}
19891998

19901999
var (selectorText, selectorMap) =
@@ -2112,6 +2121,9 @@ final class _EvaluateVisitor
21122121
throw _exception(
21132122
"Supports rules may not be used within nested declarations.",
21142123
node.span);
2124+
} else if (_inKeyframes && _parent is CssKeyframeBlock) {
2125+
throw _exception(
2126+
"At-rules may not be used within keyframe blocks.", node.span);
21152127
}
21162128

21172129
var condition = CssValue(
@@ -3270,6 +3282,9 @@ final class _EvaluateVisitor
32703282
if (_declarationName != null) {
32713283
throw _exception(
32723284
"At-rules may not be used within nested declarations.", node.span);
3285+
} else if (_inKeyframes && _parent is CssKeyframeBlock) {
3286+
throw _exception(
3287+
"At-rules may not be used within keyframe blocks.", node.span);
32733288
}
32743289

32753290
if (node.isChildless) {
@@ -3353,6 +3368,9 @@ final class _EvaluateVisitor
33533368
if (_declarationName != null) {
33543369
throw _exception(
33553370
"Media rules may not be used within nested declarations.", node.span);
3371+
} else if (_inKeyframes && _parent is CssKeyframeBlock) {
3372+
throw _exception(
3373+
"At-rules may not be used within keyframe blocks.", node.span);
33563374
}
33573375

33583376
var mergedQueries = _mediaQueries.andThen(
@@ -3401,6 +3419,9 @@ final class _EvaluateVisitor
34013419
if (_declarationName != null) {
34023420
throw _exception(
34033421
"Style rules may not be used within nested declarations.", node.span);
3422+
} else if (_inKeyframes && _parent is CssKeyframeBlock) {
3423+
throw _exception(
3424+
"Style rules may not be used within keyframe blocks.", node.span);
34043425
}
34053426

34063427
var styleRule = _styleRule;

lib/src/visitor/evaluate.dart

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// DO NOT EDIT. This file was generated from async_evaluate.dart.
66
// See tool/grind/synchronize.dart for details.
77
//
8-
// Checksum: 05cb957cd0c7698d8ad648f31d862dc91f0daa7b
8+
// Checksum: 135bf44f65efcbebb4a55b38ada86c754fcdb86b
99
//
1010
// ignore_for_file: unused_import
1111

@@ -1321,6 +1321,9 @@ final class _EvaluateVisitor
13211321
if (_declarationName != null) {
13221322
throw _exception(
13231323
"At-rules may not be used within nested declarations.", node.span);
1324+
} else if (_inKeyframes && _parent is CssKeyframeBlock) {
1325+
throw _exception(
1326+
"At-rules may not be used within keyframe blocks.", node.span);
13241327
}
13251328

13261329
var name = _interpolationToValue(node.name);
@@ -1887,6 +1890,9 @@ final class _EvaluateVisitor
18871890
if (_declarationName != null) {
18881891
throw _exception(
18891892
"Media rules may not be used within nested declarations.", node.span);
1893+
} else if (_inKeyframes && _parent is CssKeyframeBlock) {
1894+
throw _exception(
1895+
"At-rules may not be used within keyframe blocks.", node.span);
18901896
}
18911897

18921898
var queries = _visitMediaQueries(node.query);
@@ -1975,6 +1981,9 @@ final class _EvaluateVisitor
19751981
if (_declarationName != null) {
19761982
throw _exception(
19771983
"Style rules may not be used within nested declarations.", node.span);
1984+
} else if (_inKeyframes && _parent is CssKeyframeBlock) {
1985+
throw _exception(
1986+
"Style rules may not be used within keyframe blocks.", node.span);
19781987
}
19791988

19801989
var (selectorText, selectorMap) =
@@ -2102,6 +2111,9 @@ final class _EvaluateVisitor
21022111
throw _exception(
21032112
"Supports rules may not be used within nested declarations.",
21042113
node.span);
2114+
} else if (_inKeyframes && _parent is CssKeyframeBlock) {
2115+
throw _exception(
2116+
"At-rules may not be used within keyframe blocks.", node.span);
21052117
}
21062118

21072119
var condition =
@@ -3240,6 +3252,9 @@ final class _EvaluateVisitor
32403252
if (_declarationName != null) {
32413253
throw _exception(
32423254
"At-rules may not be used within nested declarations.", node.span);
3255+
} else if (_inKeyframes && _parent is CssKeyframeBlock) {
3256+
throw _exception(
3257+
"At-rules may not be used within keyframe blocks.", node.span);
32433258
}
32443259

32453260
if (node.isChildless) {
@@ -3323,6 +3338,9 @@ final class _EvaluateVisitor
33233338
if (_declarationName != null) {
33243339
throw _exception(
33253340
"Media rules may not be used within nested declarations.", node.span);
3341+
} else if (_inKeyframes && _parent is CssKeyframeBlock) {
3342+
throw _exception(
3343+
"At-rules may not be used within keyframe blocks.", node.span);
33263344
}
33273345

33283346
var mergedQueries = _mediaQueries.andThen(
@@ -3369,6 +3387,9 @@ final class _EvaluateVisitor
33693387
if (_declarationName != null) {
33703388
throw _exception(
33713389
"Style rules may not be used within nested declarations.", node.span);
3390+
} else if (_inKeyframes && _parent is CssKeyframeBlock) {
3391+
throw _exception(
3392+
"Style rules may not be used within keyframe blocks.", node.span);
33723393
}
33733394

33743395
var styleRule = _styleRule;

pkg/sass_api/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 10.2.1
2+
3+
* No user-visible changes.
4+
15
## 10.2.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: 10.2.0
5+
version: 10.2.1-dev
66
description: Additional APIs for Dart Sass.
77
homepage: https://github.com/sass/dart-sass
88

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

1212
dependencies:
13-
sass: 1.75.0
13+
sass: 1.75.1
1414

1515
dev_dependencies:
1616
dartdoc: ^6.0.0

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.75.0
2+
version: 1.75.1-dev
33
description: A Sass implementation in Dart.
44
homepage: https://github.com/sass/dart-sass
55

0 commit comments

Comments
 (0)