From 048b17495ef005b5ee2db93c984da9d7afb69fa3 Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Wed, 5 Sep 2018 14:31:59 -0700 Subject: [PATCH] Support browser hacks in plain CSS mode (#468) Closes #466 --- CHANGELOG.md | 4 ++++ lib/src/parse/stylesheet.dart | 19 ++++++++++++++++++- pubspec.yaml | 2 +- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 18b6f3d6..6a6fa686 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.13.2 + +* Fix support for CSS hacks in plain CSS mode. + ## 1.13.1 * Allow an IE-style single equals operator in plain CSS imports. diff --git a/lib/src/parse/stylesheet.dart b/lib/src/parse/stylesheet.dart index 32c32167..7a655862 100644 --- a/lib/src/parse/stylesheet.dart +++ b/lib/src/parse/stylesheet.dart @@ -370,7 +370,24 @@ abstract class StylesheetParser extends Parser { @protected Declaration _declaration() { var start = scanner.state; - var name = interpolatedIdentifier(); + + Interpolation name; + // Allow the "*prop: val", ":prop: val", "#prop: val", and ".prop: val" + // hacks. + var first = scanner.peekChar(); + if (first == $colon || + first == $asterisk || + first == $dot || + (first == $hash && scanner.peekChar(1) != $lbrace)) { + var nameBuffer = new InterpolationBuffer(); + nameBuffer.writeCharCode(scanner.readChar()); + nameBuffer.write(rawText(whitespace)); + nameBuffer.addInterpolation(interpolatedIdentifier()); + name = nameBuffer.interpolation(scanner.spanFrom(start)); + } else { + name = interpolatedIdentifier(); + } + whitespace(); scanner.expectChar($colon); whitespace(); diff --git a/pubspec.yaml b/pubspec.yaml index fe82244b..2e65fcfc 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: sass -version: 1.13.1 +version: 1.13.2-dev description: A Sass implementation in Dart. author: Dart Team homepage: https://github.com/sass/dart-sass