Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
the order they appear in the source even when they're interleaved with nested
rules. This obsoletes the `mixed-decls` deprecation.

* **Breaking change:** The function name `type()` is now fully reserved for the
plain CSS function. This means that `@function` definitions with the name
`type` will produce errors, while function calls will be parsed as special
function strings.

* Fix a bug where `@extend` rules loaded through a mixture of `@import` and
`@use` rules could fail to apply correctly.

Expand Down
6 changes: 4 additions & 2 deletions lib/src/deprecation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ enum Deprecation {
// DO NOT EDIT. This section was generated from the language repo.
// See tool/grind/generate_deprecations.dart for details.
//
// Checksum: 2a2a94a3dd8ab2f7e3880b24e8e7850d66998b33
// Checksum: 247ee9ef1df8665b759064856492831661b08985

/// Deprecation for passing a string directly to meta.call().
callString('call-string',
Expand Down Expand Up @@ -125,7 +125,9 @@ enum Deprecation {

/// Deprecation for functions named "type".
typeFunction('type-function',
deprecatedIn: '1.86.0', description: 'Functions named "type".'),
deprecatedIn: '1.86.0',
obsoleteIn: '1.92.0',
description: 'Functions named "type".'),

/// Deprecation for passing a relative url to compileString().
compileStringRelativeUrl('compile-string-relative-url',
Expand Down
67 changes: 33 additions & 34 deletions lib/src/parse/stylesheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -932,14 +932,8 @@ abstract class StylesheetParser extends Parser {
span: scanner.spanFrom(beforeName),
));
} else if (equalsIgnoreCase(name, 'type')) {
warnings.add((
deprecation: Deprecation.typeFunction,
message: 'Sass @functions named "type" are deprecated for forward-'
'compatibility with the plain CSS type() function.\n'
'\n'
'For details, see https://sass-lang.com/d/type-function',
span: scanner.spanFrom(beforeName),
));
error('This name is reserved for the plain-CSS function.',
scanner.spanFrom(beforeName));
}

whitespace(consumeNewlines: true);
Expand Down Expand Up @@ -2966,35 +2960,40 @@ abstract class StylesheetParser extends Parser {
/// [name].
@protected
Expression? trySpecialFunction(String name, LineScannerState start) {
var normalized = unvendor(name);

InterpolationBuffer buffer;
switch (normalized) {
case "calc" when normalized != name && scanner.scanChar($lparen):
case "element" || "expression" when scanner.scanChar($lparen):
buffer = InterpolationBuffer()
..write(name)
..writeCharCode($lparen);

case "progid" when scanner.scanChar($colon):
buffer = InterpolationBuffer()
..write(name)
..writeCharCode($colon);
var next = scanner.peekChar();
while (next != null && (next.isAlphabetic || next == $dot)) {
buffer.writeCharCode(scanner.readChar());
next = scanner.peekChar();
}
scanner.expectChar($lparen);
buffer.writeCharCode($lparen);
if (name == "type" && scanner.scanChar($lparen)) {
buffer = InterpolationBuffer()
..write(name)
..writeCharCode($lparen);
} else {
var normalized = unvendor(name);
switch (normalized) {
case "calc" when normalized != name && scanner.scanChar($lparen):
case "element" || "expression" when scanner.scanChar($lparen):
buffer = InterpolationBuffer()
..write(name)
..writeCharCode($lparen);

case "progid" when scanner.scanChar($colon):
buffer = InterpolationBuffer()
..write(name)
..writeCharCode($colon);
var next = scanner.peekChar();
while (next != null && (next.isAlphabetic || next == $dot)) {
buffer.writeCharCode(scanner.readChar());
next = scanner.peekChar();
}
scanner.expectChar($lparen);
buffer.writeCharCode($lparen);

case "url":
return _tryUrlContents(
start,
).andThen((contents) => StringExpression(contents));
case "url":
return _tryUrlContents(
start,
).andThen((contents) => StringExpression(contents));

case _:
return null;
case _:
return null;
}
}

buffer.addInterpolation(_interpolatedDeclarationValue(allowEmpty: true));
Expand Down
Loading