diff --git a/CHANGELOG.md b/CHANGELOG.md index 262305235..0e27ae48c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,14 @@ -## 1.85.2-dev +## 1.86.0 + +* Add support for `%` as an expression in its own right. It will still be parsed + as the modulo operator when between two other expressions, but in any other + context it will be an expression whose value is the unquoted string `%`. + +* Consider `attr()` to be a special number function that can be used as a + channel in color functions. + +* Deprecate user-defined functions named `type()` so that we can eventually + support the new CSS `type()` function. ### Dart API diff --git a/lib/src/deprecation.dart b/lib/src/deprecation.dart index dff00aab5..db1789ac7 100644 --- a/lib/src/deprecation.dart +++ b/lib/src/deprecation.dart @@ -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: 47c97f7824eb25d7f1e64e3230938b88330d40b4 + // Checksum: 3639e60773866019c018ae16267c8f23e4df86cf /// Deprecation for passing a string directly to meta.call(). callString( @@ -166,6 +166,13 @@ enum Deprecation { 'Global built-in functions that are available in sass: modules.', ), + /// Deprecation for functions named "type". + typeFunction( + 'type-function', + deprecatedIn: '1.86.0', + description: 'Functions named "type".', + ), + // END AUTOGENERATED CODE /// Used for deprecations coming from user-authored code. diff --git a/lib/src/parse/stylesheet.dart b/lib/src/parse/stylesheet.dart index 62cc99eba..ae02a7598 100644 --- a/lib/src/parse/stylesheet.dart +++ b/lib/src/parse/stylesheet.dart @@ -923,11 +923,20 @@ abstract class StylesheetParser extends Parser { deprecation: Deprecation.cssFunctionMixin, message: 'Sass @function names beginning with -- are deprecated for forward-' - 'compatibility with plain CSS mixins.\n' + 'compatibility with plain CSS functions.\n' '\n' 'For details, see https://sass-lang.com/d/css-function-mixin', 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), + )); } whitespace(consumeNewlines: true); @@ -2079,7 +2088,6 @@ abstract class StylesheetParser extends Parser { operators.last.precedence >= operator.precedence) { resolveOneOperation(); } - operators.add(operator); var singleExpression = singleExpression_; if (singleExpression == null) { @@ -2089,9 +2097,16 @@ abstract class StylesheetParser extends Parser { length: operator.operator.length, ); } - operands.add(singleExpression); whitespace(consumeNewlines: true); - singleExpression_ = _singleExpression(); + + if (operator == BinaryOperator.modulo && !_lookingAtExpression()) { + addSingleExpression(StringExpression.plain( + '%', scanner.spanFromPosition(scanner.position - 1))); + } else { + operators.add(operator); + operands.add(singleExpression); + singleExpression_ = _singleExpression(); + } } void resolveSpaceExpressions() { @@ -2353,6 +2368,7 @@ abstract class StylesheetParser extends Parser { $plus => _plusExpression(), $minus => _minusExpression(), $exclamation => _importantExpression(), + $percent => _percentExpression(), // dart-lang/sdk#52740 // ignore: non_constant_relational_pattern_expression $u || $U when scanner.peekChar(1) == $plus => _unicodeRange(), @@ -2553,6 +2569,15 @@ abstract class StylesheetParser extends Parser { return StringExpression.plain("!important", scanner.spanFrom(start)); } + /// Consumes a `%` expression. + Expression _percentExpression() { + assert(scanner.peekChar() == $percent); + + var start = scanner.state; + scanner.readChar(); + return StringExpression.plain("%", scanner.spanFrom(start)); + } + /// Consumes a unary operation expression. UnaryOperationExpression _unaryOperation() { var start = scanner.state; @@ -3799,6 +3824,7 @@ abstract class StylesheetParser extends Parser { $backslash || $dollar || $ampersand || + $percent || int(isNameStart: true) || int(isDigit: true) => true, diff --git a/lib/src/value/string.dart b/lib/src/value/string.dart index 164db2e24..1652bfeed 100644 --- a/lib/src/value/string.dart +++ b/lib/src/value/string.dart @@ -71,6 +71,10 @@ class SassString extends Value { if (text.length < "min(_)".length) return false; return switch (text.codeUnitAt(0)) { + $a || $A => equalsLetterIgnoreCase($t, text.codeUnitAt(1)) && + equalsLetterIgnoreCase($t, text.codeUnitAt(2)) && + equalsLetterIgnoreCase($r, text.codeUnitAt(3)) && + text.codeUnitAt(4) == $lparen, $c || $C => switch (text.codeUnitAt(1)) { $l || $L => equalsLetterIgnoreCase($a, text.codeUnitAt(2)) && equalsLetterIgnoreCase($m, text.codeUnitAt(3)) && diff --git a/pkg/sass-parser/CHANGELOG.md b/pkg/sass-parser/CHANGELOG.md index 086099478..0bf7bf97c 100644 --- a/pkg/sass-parser/CHANGELOG.md +++ b/pkg/sass-parser/CHANGELOG.md @@ -1,4 +1,4 @@ -## 0.4.16-dev +## 0.4.16 * Use union types rather than base classes for Sass nodes wherever possible. This makes it possible for TypeScript to automatically narrow node types based diff --git a/pkg/sass-parser/package.json b/pkg/sass-parser/package.json index 95ed2fa39..ad1dfd53a 100644 --- a/pkg/sass-parser/package.json +++ b/pkg/sass-parser/package.json @@ -1,6 +1,6 @@ { "name": "sass-parser", - "version": "0.4.16-dev", + "version": "0.4.16", "description": "A PostCSS-compatible wrapper of the official Sass parser", "repository": "sass/sass", "author": "Google Inc.", diff --git a/pkg/sass_api/CHANGELOG.md b/pkg/sass_api/CHANGELOG.md index 0c550d685..e4fe10e4b 100644 --- a/pkg/sass_api/CHANGELOG.md +++ b/pkg/sass_api/CHANGELOG.md @@ -1,4 +1,4 @@ -## 15.2.2-dev +## 15.3.0 * No user-visible changes. diff --git a/pkg/sass_api/pubspec.yaml b/pkg/sass_api/pubspec.yaml index 160bb9d81..2e3e37a27 100644 --- a/pkg/sass_api/pubspec.yaml +++ b/pkg/sass_api/pubspec.yaml @@ -2,7 +2,7 @@ name: sass_api # Note: Every time we add a new Sass AST node, we need to bump the *major* # version because it's a breaking change for anyone who's implementing the # visitor interface(s). -version: 15.2.2-dev +version: 15.3.0 description: Additional APIs for Dart Sass. homepage: https://github.com/sass/dart-sass @@ -10,7 +10,7 @@ environment: sdk: ">=3.6.0 <4.0.0" dependencies: - sass: 1.85.2 + sass: 1.86.0 dev_dependencies: dartdoc: ^8.0.14 diff --git a/pubspec.yaml b/pubspec.yaml index b1a35148c..36cd1aefa 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: sass -version: 1.85.2-dev +version: 1.86.0 description: A Sass implementation in Dart. homepage: https://github.com/sass/dart-sass