Merge branch 'master' of git://github.com/sass/dart-sass into interactive

This commit is contained in:
Jen Thakar 2018-04-14 20:28:15 -07:00
commit 7c64f222e0
5 changed files with 49 additions and 11 deletions

View File

@ -6,6 +6,8 @@
* Properly parse `#{$var} -#{$var}` as two separate values in a list rather than
one value being subtracted from another.
* Improve the error message for extending compound selectors.
## 1.1.1
* Add a commit that was accidentally left out of 1.1.0.

View File

@ -45,7 +45,7 @@ class SelectorParser extends Parser {
SimpleSelector parseSimpleSelector() {
return wrapSpanFormatException(() {
var simple = _simpleSelector();
if (!scanner.isDone) scanner.error("expected selector.");
if (!scanner.isDone) scanner.error("unexpected token.");
return simple;
});
}

View File

@ -545,10 +545,28 @@ class _EvaluateVisitor
var targetText =
await _interpolationToValue(node.selector, warnForColor: true);
var target = _adjustParseError(
targetText.span,
() => new SimpleSelector.parse(targetText.value.trim(),
logger: _logger, allowParent: false));
var target = _adjustParseError(targetText.span, () {
try {
return new SimpleSelector.parse(targetText.value.trim(),
logger: _logger, allowParent: false);
} on SassFormatException catch (error) {
CompoundSelector compound;
try {
compound = new CompoundSelector.parse(targetText.value.trim(),
logger: _logger, allowParent: false);
} on SassFormatException {
throw error;
}
// If the selector was a compound selector but not a simple
// selector, emit a more explicit error.
throw new SassFormatException(
"compound selectors may longer be extended.\n"
"Consider `@extend ${compound.components.join(', ')}` instead.\n"
"See http://bit.ly/ExtendCompound for details.\n",
error.span);
}
});
_extender.addExtension(_styleRule.selector, target, node, _mediaQueries);
return null;
}

View File

@ -5,7 +5,7 @@
// DO NOT EDIT. This file was generated from async_evaluate.dart.
// See tool/synchronize.dart for details.
//
// Checksum: 4eb54f9170b6c2a337afb7c86502a1a78a0e280f
// Checksum: 6853f090ba925c445687ea776dd5c94095aa6806
import 'dart:math' as math;
@ -541,10 +541,28 @@ class _EvaluateVisitor
var targetText = _interpolationToValue(node.selector, warnForColor: true);
var target = _adjustParseError(
targetText.span,
() => new SimpleSelector.parse(targetText.value.trim(),
logger: _logger, allowParent: false));
var target = _adjustParseError(targetText.span, () {
try {
return new SimpleSelector.parse(targetText.value.trim(),
logger: _logger, allowParent: false);
} on SassFormatException catch (error) {
CompoundSelector compound;
try {
compound = new CompoundSelector.parse(targetText.value.trim(),
logger: _logger, allowParent: false);
} on SassFormatException {
throw error;
}
// If the selector was a compound selector but not a simple
// selector, emit a more explicit error.
throw new SassFormatException(
"compound selectors may longer be extended.\n"
"Consider `@extend ${compound.components.join(', ')}` instead.\n"
"See http://bit.ly/ExtendCompound for details.\n",
error.span);
}
});
_extender.addExtension(_styleRule.selector, target, node, _mediaQueries);
return null;
}

View File

@ -1,5 +1,5 @@
name: sass
version: 1.2.0-dev
version: 1.2.0
description: A Sass implementation in Dart.
author: Dart Team <misc@dartlang.org>
homepage: https://github.com/sass/dart-sass