declarationValue()

This commit is contained in:
Natalie Weizenbaum 2016-05-24 09:35:57 -07:00
parent 0b6e7669ec
commit fcb0b7d29e
2 changed files with 14 additions and 4 deletions

View File

@ -14,8 +14,11 @@ class InterpolationExpression implements Expression {
/// If this contains no interpolation, returns the plain text it contains.
///
/// Otherwise, returns `null`.
String get asPlain =>
contents.length == 1 && contents.first is String ? contents.first : null;
String get asPlain {
if (contents.isEmpty) return '';
if (contents.length == 1 && contents.first is String) return contents.first;
return null;
}
/// Returns the plain text before the interpolation, or the empty string.
String get initialPlain => contents.first is String ? contents.first : '';

View File

@ -132,11 +132,18 @@ class Parser {
return children;
}
Expression _declarationValue() {
if (_scanner.peekChar() == $lbrace) {
return new StringExpression([], span: _scanner.emptySpan);
}
// TODO: parse static values specially?
return _expression();
}
AstNode _customPropertyDeclaration(InterpolationExpression name) =>
throw new UnimplementedError();
Expression _declarationValue() => throw new UnimplementedError();
/// Parses a [DeclarationNode] or a [StyleRuleNode].
///
/// When parsing the contents of a style rule, it can be difficult to tell