Skip to content

Commit c0359d6

Browse files
authored
Drop support for special @-moz-document parsing (#2428)
1 parent 01a2148 commit c0359d6

11 files changed

+26
-103
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 2.0.0
2+
3+
* **Breaking change:** The `@-moz-document` rule no longer has any special
4+
parsing associated with it. It is now parsed like any other unknown plain CSS
5+
at-rule, where Sass features are only allowed within `#{}` interpolation.
6+
17
## 1.80.6
28

39
### Command-Line Interface

lib/src/deprecation.dart

+7-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ enum Deprecation {
1515
// DO NOT EDIT. This section was generated from the language repo.
1616
// See tool/grind/generate_deprecations.dart for details.
1717
//
18-
// Checksum: 47c97f7824eb25d7f1e64e3230938b88330d40b4
18+
// Checksum: 651decb8bf8d0378b657241a5a0db7272c228fd4
1919

2020
/// Deprecation for passing a string directly to meta.call().
2121
callString('call-string',
@@ -27,7 +27,9 @@ enum Deprecation {
2727

2828
/// Deprecation for @-moz-document.
2929
mozDocument('moz-document',
30-
deprecatedIn: '1.7.2', description: '@-moz-document.'),
30+
deprecatedIn: '1.7.2',
31+
obsoleteIn: '2.0.0',
32+
description: '@-moz-document.'),
3133

3234
/// Deprecation for imports using relative canonical URLs.
3335
relativeCanonical('relative-canonical',
@@ -175,9 +177,10 @@ enum Deprecation {
175177
Version? get obsoleteIn => _obsoleteIn?.andThen(Version.parse);
176178

177179
/// Constructs a regular deprecation.
178-
const Deprecation(this.id, {required String? deprecatedIn, this.description})
180+
const Deprecation(this.id,
181+
{required String? deprecatedIn, this.description, String? obsoleteIn})
179182
: _deprecatedIn = deprecatedIn,
180-
_obsoleteIn = null,
183+
_obsoleteIn = obsoleteIn,
181184
isFuture = false;
182185

183186
/// Constructs a future deprecation.

lib/src/js/deprecations.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ final Map<String, Deprecation?> deprecations = {
4242
})(),
4343
description: deprecation.description,
4444
deprecatedIn: deprecation.deprecatedIn,
45-
obsoleteIn: deprecation.deprecatedIn),
45+
obsoleteIn: deprecation.obsoleteIn),
4646
};
4747

4848
/// Parses a list of [deprecations] from JS into an list of Dart [Deprecation]

lib/src/parse/css.dart

-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ class CssParser extends ScssParser {
6969
_forbiddenAtRule(start),
7070
"import" => _cssImportRule(start),
7171
"media" => mediaRule(start),
72-
"-moz-document" => mozDocumentRule(start, name),
7372
"supports" => supportsRule(start),
7473
_ => unknownAtRule(start, name)
7574
};

lib/src/parse/stylesheet.dart

-87
Original file line numberDiff line numberDiff line change
@@ -651,8 +651,6 @@ abstract class StylesheetParser extends Parser {
651651
return mediaRule(start);
652652
case "mixin":
653653
return _mixinRule(start);
654-
case "-moz-document":
655-
return mozDocumentRule(start, name);
656654
case "return":
657655
return _disallowedAtRule(start);
658656
case "supports":
@@ -1345,91 +1343,6 @@ abstract class StylesheetParser extends Parser {
13451343
});
13461344
}
13471345

1348-
/// Consumes a `@moz-document` rule.
1349-
///
1350-
/// Gecko's `@-moz-document` diverges from [the specification][] allows the
1351-
/// `url-prefix` and `domain` functions to omit quotation marks, contrary to
1352-
/// the standard.
1353-
///
1354-
/// [the specification]: http://www.w3.org/TR/css3-conditional/
1355-
@protected
1356-
AtRule mozDocumentRule(LineScannerState start, Interpolation name) {
1357-
var valueStart = scanner.state;
1358-
var buffer = InterpolationBuffer();
1359-
var needsDeprecationWarning = false;
1360-
while (true) {
1361-
if (scanner.peekChar() == $hash) {
1362-
var (expression, span) = singleInterpolation();
1363-
buffer.add(expression, span);
1364-
needsDeprecationWarning = true;
1365-
} else {
1366-
var identifierStart = scanner.state;
1367-
var identifier = this.identifier();
1368-
switch (identifier) {
1369-
case "url" || "url-prefix" || "domain":
1370-
if (_tryUrlContents(identifierStart, name: identifier)
1371-
case var contents?) {
1372-
buffer.addInterpolation(contents);
1373-
} else {
1374-
scanner.expectChar($lparen);
1375-
whitespace();
1376-
var argument = interpolatedString();
1377-
scanner.expectChar($rparen);
1378-
1379-
buffer
1380-
..write(identifier)
1381-
..writeCharCode($lparen)
1382-
..addInterpolation(argument.asInterpolation())
1383-
..writeCharCode($rparen);
1384-
}
1385-
1386-
// A url-prefix with no argument, or with an empty string as an
1387-
// argument, is not (yet) deprecated.
1388-
var trailing = buffer.trailingString;
1389-
if (!trailing.endsWith("url-prefix()") &&
1390-
!trailing.endsWith("url-prefix('')") &&
1391-
!trailing.endsWith('url-prefix("")')) {
1392-
needsDeprecationWarning = true;
1393-
}
1394-
1395-
case "regexp":
1396-
buffer.write("regexp(");
1397-
scanner.expectChar($lparen);
1398-
buffer.addInterpolation(interpolatedString().asInterpolation());
1399-
scanner.expectChar($rparen);
1400-
buffer.writeCharCode($rparen);
1401-
needsDeprecationWarning = true;
1402-
1403-
default:
1404-
error("Invalid function name.", scanner.spanFrom(identifierStart));
1405-
}
1406-
}
1407-
1408-
whitespace();
1409-
if (!scanner.scanChar($comma)) break;
1410-
1411-
buffer.writeCharCode($comma);
1412-
buffer.write(rawText(whitespace));
1413-
}
1414-
1415-
var value = buffer.interpolation(scanner.spanFrom(valueStart));
1416-
return _withChildren(_statement, start, (children, span) {
1417-
if (needsDeprecationWarning) {
1418-
warnings.add((
1419-
deprecation: Deprecation.mozDocument,
1420-
message:
1421-
"@-moz-document is deprecated and support will be removed in "
1422-
"Dart Sass 2.0.0.\n"
1423-
"\n"
1424-
"For details, see https://sass-lang.com/d/moz-document.",
1425-
span: span
1426-
));
1427-
}
1428-
1429-
return AtRule(name, span, value: value, children: children);
1430-
});
1431-
}
1432-
14331346
/// Consumes a `@return` rule.
14341347
///
14351348
/// [start] should point before the `@`.

pkg/sass-parser/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.5.0
2+
3+
* No user-visible changes.
4+
15
## 0.4.3
26

37
* Add support for parsing the `@while` rule.

pkg/sass-parser/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sass-parser",
3-
"version": "0.4.3",
3+
"version": "0.5.0-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

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 15.0.0
2+
3+
* No user-visible changes.
4+
15
## 14.1.2
26

37
* No user-visible changes.

pkg/sass_api/pubspec.yaml

+2-2
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: 14.1.2
5+
version: 15.0.0-dev
66
description: Additional APIs for Dart Sass.
77
homepage: https://github.com/sass/dart-sass
88

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

1212
dependencies:
13-
sass: 1.80.6
13+
sass: 2.0.0
1414

1515
dev_dependencies:
1616
dartdoc: ^8.0.14

pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: sass
2-
version: 1.80.6
2+
version: 2.0.0-dev
33
description: A Sass implementation in Dart.
44
homepage: https://github.com/sass/dart-sass
55

test/deprecations_test.dart

-6
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@ void main() {
2020
_expectDeprecation("@if false {} @elseif false {}", Deprecation.elseif);
2121
});
2222

23-
// Deprecated in 1.7.2
24-
test("mozDocument is violated by most @-moz-document rules", () {
25-
_expectDeprecation(
26-
"@-moz-document url-prefix(foo) {}", Deprecation.mozDocument);
27-
});
28-
2923
// Deprecated in 1.17.2
3024
test("newGlobal is violated by declaring a new variable with !global", () {
3125
_expectDeprecation(r"a {$foo: bar !global;}", Deprecation.newGlobal);

0 commit comments

Comments
 (0)