Skip to content

Commit

Permalink
Add support for @elseif (#317)
Browse files Browse the repository at this point in the history
Closes #316
  • Loading branch information
nex3 authored May 4, 2018
1 parent d9d55f1 commit 2d72f1c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 1.3.2

* Add support for `@elseif` as an alias of `@else if`. This is not an
intentional feature, so using it will cause a deprecation warning. It will be
removed at some point in the future.

## 1.3.1

### Node API
Expand Down
7 changes: 4 additions & 3 deletions lib/src/parse/parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ abstract class Parser {
final SpanScanner scanner;

/// The logger to use when emitting warnings.
final Logger _logger;
@protected
final Logger logger;

Parser(String contents, {url, Logger logger})
: scanner = new SpanScanner(contents, sourceUrl: url),
_logger = logger ?? const Logger.stderr();
logger = logger ?? const Logger.stderr();

// ## Tokens

Expand Down Expand Up @@ -566,7 +567,7 @@ abstract class Parser {

/// Prints a warning to standard error, associated with [span].
@protected
void warn(String message, FileSpan span) => _logger.warn(message, span: span);
void warn(String message, FileSpan span) => logger.warn(message, span: span);

/// Prints a source span highlight of the current location being scanned.
///
Expand Down
15 changes: 14 additions & 1 deletion lib/src/parse/scss.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,20 @@ class ScssParser extends StylesheetParser {
bool scanElse(int _) {
var start = scanner.state;
whitespace();
if (scanner.scanChar($at) && scanIdentifier('else')) return true;
var beforeAt = scanner.state;
if (scanner.scanChar($at)) {
if (scanIdentifier('else')) return true;
if (scanIdentifier('elseif')) {
logger.warn(
'@elseif is deprecated and will not be supported in future Sass '
'versions.\n'
'Use "@else if" instead.',
span: scanner.spanFrom(beforeAt),
deprecation: true);
scanner.position -= 2;
return true;
}
}
scanner.state = start;
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: sass
version: 1.3.1
version: 1.3.2
description: A Sass implementation in Dart.
author: Dart Team <[email protected]>
homepage: https://github.com/sass/dart-sass
Expand Down

0 comments on commit 2d72f1c

Please sign in to comment.