diff --git a/CHANGELOG.md b/CHANGELOG.md index 53f152437..61562152c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,22 +1,50 @@ -## 1.55.1 +## 1.56.0 + +* **Potentially breaking change:** To match the CSS spec, SassScript expressions + beginning with `not` or `(` are no longer supported at the beginning of + parenthesized sections of media queries. For example, + + ```scss + @media (width >= 500px) and (not (grid)) + ``` + + will now be emitted unchanged, instead of producing + + ```scss + @media (width >= 500px) and (false) + ``` + + See [the Sass website](https://sass-lang.com/d/media-logic) for details. * **Potentially breaking bug fix:** Angle units like `rad` or `turn` are now properly converted to equivalent `deg` values for `hsl()`, `hsla()`, `adjust-hue()`, `color.adjust()`, and `color.change()`. + See [the Sass website](https://sass-lang.com/d/function-units#hue) for + details. + * Fix indentation for selectors that span multiple lines in a `@media` query. * Emit a deprecation warning when passing `$alpha` values with units to `color.adjust()` or `color.change()`. This will be an error in Dart Sass 2.0.0. + See [the Sass website](https://sass-lang.com/d/function-units#alpha) for + details. + * Emit a deprecation warning when passing a `$weight` value with no units or with units other than `%` to `color.mix()`. This will be an error in Dart Sass 2.0.0. + See [the Sass website](https://sass-lang.com/d/function-units#weight) for + details. + * Emit a deprecation warning when passing `$n` values with units to `list.nth()` or `list.set-nth()`. This will be an error in Dart Sass 2.0.0. + See [the Sass website](https://sass-lang.com/d/function-units#index) for + details. + * Improve existing deprecation warnings to wrap `/`-as-division suggestions in `calc()` expressions. diff --git a/lib/src/parse/stylesheet.dart b/lib/src/parse/stylesheet.dart index c1326af59..ac3e9f582 100644 --- a/lib/src/parse/stylesheet.dart +++ b/lib/src/parse/stylesheet.dart @@ -3594,52 +3594,54 @@ abstract class StylesheetParser extends Parser { buffer.writeCharCode($lparen); whitespace(); - var needsParenDeprecation = scanner.peekChar() == $lparen; - var needsNotDeprecation = matchesIdentifier("not"); - - var expression = _expressionUntilComparison(); - if (needsParenDeprecation || needsNotDeprecation) { - logger.warn( - 'Starting a @media query with "${needsParenDeprecation ? '(' : 'not'}" ' - "is deprecated because it conflicts with official CSS syntax.\n" - "\n" - "To preserve existing behavior: #{$expression}\n" - 'To migrate to new behavior: #{"$expression"}\n' - "\n" - "For details, see https://sass-lang.com/d/media-logic", - span: expression.span, - deprecation: true); - } - - buffer.add(expression); - if (scanner.scanChar($colon)) { + if (scanner.peekChar() == $lparen) { + _mediaInParens(buffer); whitespace(); - buffer.writeCharCode($colon); - buffer.writeCharCode($space); - buffer.add(_expression()); + if (scanIdentifier("and")) { + buffer.write(" and "); + expectWhitespace(); + _mediaLogicSequence(buffer, "and"); + } else if (scanIdentifier("or")) { + buffer.write(" or "); + expectWhitespace(); + _mediaLogicSequence(buffer, "or"); + } + } else if (scanIdentifier("not")) { + buffer.write("not "); + expectWhitespace(); + _mediaOrInterp(buffer); } else { - var next = scanner.peekChar(); - if (next == $langle || next == $rangle || next == $equal) { - buffer.writeCharCode($space); - buffer.writeCharCode(scanner.readChar()); - if ((next == $langle || next == $rangle) && scanner.scanChar($equal)) { - buffer.writeCharCode($equal); - } - buffer.writeCharCode($space); - + buffer.add(_expressionUntilComparison()); + if (scanner.scanChar($colon)) { whitespace(); - buffer.add(_expressionUntilComparison()); - - if ((next == $langle || next == $rangle) && - // dart-lang/sdk#45356 - scanner.scanChar(next!)) { + buffer.writeCharCode($colon); + buffer.writeCharCode($space); + buffer.add(_expression()); + } else { + var next = scanner.peekChar(); + if (next == $langle || next == $rangle || next == $equal) { buffer.writeCharCode($space); - buffer.writeCharCode(next); - if (scanner.scanChar($equal)) buffer.writeCharCode($equal); + buffer.writeCharCode(scanner.readChar()); + if ((next == $langle || next == $rangle) && + scanner.scanChar($equal)) { + buffer.writeCharCode($equal); + } buffer.writeCharCode($space); whitespace(); buffer.add(_expressionUntilComparison()); + + if ((next == $langle || next == $rangle) && + // dart-lang/sdk#45356 + scanner.scanChar(next!)) { + buffer.writeCharCode($space); + buffer.writeCharCode(next); + if (scanner.scanChar($equal)) buffer.writeCharCode($equal); + buffer.writeCharCode($space); + + whitespace(); + buffer.add(_expressionUntilComparison()); + } } } } diff --git a/pkg/sass_api/CHANGELOG.md b/pkg/sass_api/CHANGELOG.md index 8ef193753..0332fb86d 100644 --- a/pkg/sass_api/CHANGELOG.md +++ b/pkg/sass_api/CHANGELOG.md @@ -1,3 +1,7 @@ +## 4.1.0 + +* No user-visible changes. + ## 4.0.0 ### Dart API diff --git a/pkg/sass_api/pubspec.yaml b/pkg/sass_api/pubspec.yaml index dd22fae72..dbbca9b7a 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: 4.0.0 +version: 4.1.0 description: Additional APIs for Dart Sass. homepage: https://github.com/sass/dart-sass @@ -10,7 +10,7 @@ environment: sdk: ">=2.17.0 <3.0.0" dependencies: - sass: 1.55.0 + sass: 1.56.0 dev_dependencies: dartdoc: ^5.0.0 diff --git a/pubspec.yaml b/pubspec.yaml index ae39c83fa..dd900f2ed 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: sass -version: 1.55.1-dev +version: 1.56.0 description: A Sass implementation in Dart. homepage: https://github.com/sass/dart-sass