Enable @extend.

Still tons of runtime errors.
This commit is contained in:
Natalie Weizenbaum 2016-08-12 17:51:17 -07:00
parent 69a431c7bf
commit 69221190e7
3 changed files with 19 additions and 3 deletions

View File

@ -89,7 +89,7 @@ class Extender {
return new SelectorList(newList.where((complex) => complex != null));
}
List<ComplexSelector> _extendComplex(ComplexSelector complex,
Iterable<ComplexSelector> _extendComplex(ComplexSelector complex,
Map<SimpleSelector, Set<SelectorList>> extensions) {
// This could be written more simply using [List.map], but we want to avoid
// any allocations in the common case where no extends apply.
@ -104,8 +104,10 @@ class Extender {
if (changed) extendedNotExpanded.add([[component]]);
} else {
if (!changed) {
extendedNotExpanded =
complex.components.take(i).map((component) => [[component]]);
extendedNotExpanded = complex.components
.take(i)
.map((component) => [[component]])
.toList();
}
changed = true;
extendedNotExpanded.add(extended);

View File

@ -69,6 +69,12 @@ class Parser {
return selector;
}
SimpleSelector parseSimpleSelector() {
var simple = _simpleSelector();
_scanner.expectDone();
return simple;
}
VariableDeclaration _variableDeclaration() {
if (!_scanner.scanChar($dollar)) return null;

View File

@ -66,6 +66,14 @@ class PerformVisitor extends StatementVisitor {
_parent.addChild(new CssDeclaration(name, cssValue, span: node.span));
}
void visitExtendRule(ExtendRule node) {
var targetText = _performInterpolation(node.selector);
// TODO: recontextualize parse errors.
var simple = new Parser(targetText.value).parseSimpleSelector();
_extender.addExtension(_selector.value, simple);
}
void visitAtRule(AtRule node) {
var value = node.value == null
? null