variables.clear();
variables.putAll(variableScope);
+ // clean up insert point so that processing of the next block will
+ // insert after that block
+ lastNodeAdded.remove(originalParent);
+
// has the node been removed from its parent?
if (originalParent != null) {
- return !originalParent.getChildren().contains(node);
+ boolean removed = !originalParent.getChildren().contains(node);
+ return removed;
} else {
return false;
}
}
node.setSelectorList(newList);
Node oldParent = node.getParentNode();
+
HashMap<Node, Node> lastNodeAdded = ScssStylesheet.getLastNodeAdded();
- if (lastNodeAdded.get(oldParent) != null) {
- oldParent.getParentNode().appendChild(node,
- lastNodeAdded.get(oldParent));
- } else {
- oldParent.getParentNode().appendChild(node, oldParent);
+ Node lastAdded = lastNodeAdded.get(oldParent.getParentNode());
+ if (lastAdded == null) {
+ lastAdded = oldParent;
}
- lastNodeAdded.put(oldParent, node);
+ oldParent.getParentNode().appendChild(node, lastAdded);
+
+ lastNodeAdded.put(oldParent.getParentNode(), node);
}
}
.main .second.third .fourth {
color: black;
+}
+
+.root .first-block .nested {
+ order: first;
+}
+
+.root .last-block {
+ order: last;
}
\ No newline at end of file
color: black;
}
}
+}
+
+.root {
+ .first-block {
+ .nested {
+ order: first;
+ }
+ }
+
+ .last-block {
+ order: last;
+ }
}
\ No newline at end of file
parser.setDocumentHandler(handler);
parser.parseStyleSheet(getClass().getResource(scss).getPath());
ScssStylesheet root = handler.getStyleSheet();
- Assert.assertEquals(5, root.getChildren().size());
+ Assert.assertEquals(6, root.getChildren().size());
BlockNode blockNode0 = (BlockNode) root.getChildren().get(0);
Assert.assertEquals(2, blockNode0.getChildren().size());
BlockNode nestednestedBlockInBlock4 = (BlockNode) nestedBlockInBlock3
.getChildren().get(1);
Assert.assertEquals(1, nestednestedBlockInBlock4.getChildren().size());
+
+ // the parsing of the last block is not checked in detail
}
@Test