'>>>' and '/deep/' no longer share a token
This allows csslib to preserve the original combinator choice when printing an
AST.
diff --git a/lib/parser.dart b/lib/parser.dart
index 9b1b9ce..fa5cce8 100644
--- a/lib/parser.dart
+++ b/lib/parser.dart
@@ -1248,7 +1248,7 @@
_eat(TokenKind.GREATER);
if (_maybeEat(TokenKind.GREATER)) {
_eat(TokenKind.GREATER);
- combinatorType = TokenKind.COMBINATOR_DEEP;
+ combinatorType = TokenKind.COMBINATOR_SHADOW_PIERCING_DESCENDANT;
} else {
combinatorType = TokenKind.COMBINATOR_GREATER;
}
diff --git a/lib/src/tokenkind.dart b/lib/src/tokenkind.dart
index 2ad648a..85e6d40 100644
--- a/lib/src/tokenkind.dart
+++ b/lib/src/tokenkind.dart
@@ -100,9 +100,10 @@
static const int COMBINATOR_PLUS = 515; // + combinator
static const int COMBINATOR_GREATER = 516; // > combinator
static const int COMBINATOR_TILDE = 517; // ~ combinator
- static const int COMBINATOR_DEEP = 518; // /deep/ or >>> combinator
+ static const int COMBINATOR_SHADOW_PIERCING_DESCENDANT = 518; // >>>
+ static const int COMBINATOR_DEEP = 519; // /deep/ (aliases >>>)
- static const int UNARY_OP_NONE = 519; // No unary operator present.
+ static const int UNARY_OP_NONE = 520; // No unary operator present.
// Attribute match types:
static const int INCLUDES = 530; // '~='
diff --git a/lib/src/tree.dart b/lib/src/tree.dart
index cb410ec..9b6e462 100644
--- a/lib/src/tree.dart
+++ b/lib/src/tree.dart
@@ -121,11 +121,15 @@
bool get isCombinatorDescendant =>
combinator == TokenKind.COMBINATOR_DESCENDANT;
bool get isCombinatorDeep => combinator == TokenKind.COMBINATOR_DEEP;
+ bool get isCombinatorShadowPiercingDescendant =>
+ combinator == TokenKind.COMBINATOR_SHADOW_PIERCING_DESCENDANT;
String get _combinatorToString {
switch (combinator) {
- case TokenKind.COMBINATOR_DEEP:
+ case TokenKind.COMBINATOR_SHADOW_PIERCING_DESCENDANT:
return ' >>> ';
+ case TokenKind.COMBINATOR_DEEP:
+ return ' /deep/ ';
case TokenKind.COMBINATOR_DESCENDANT:
return ' ';
case TokenKind.COMBINATOR_GREATER:
diff --git a/lib/src/tree_printer.dart b/lib/src/tree_printer.dart
index cbe0353..ac4512c 100644
--- a/lib/src/tree_printer.dart
+++ b/lib/src/tree_printer.dart
@@ -271,8 +271,10 @@
output.writeValue('combinator', ">");
} else if (node.isCombinatorTilde) {
output.writeValue('combinator', "~");
- } else if (node.isCombinatorDeep) {
+ } else if (node.isCombinatorShadowPiercingDescendant) {
output.writeValue('combinator', '>>>');
+ } else if (node.isCombinatorDeep) {
+ output.writeValue('combinator', '/deep/');
} else {
output.writeValue('combinator', "ERROR UNKNOWN");
}
diff --git a/test/selector_test.dart b/test/selector_test.dart
index a121223..66e2080 100644
--- a/test/selector_test.dart
+++ b/test/selector_test.dart
@@ -61,7 +61,7 @@
selectorAst = selector('.a /deep/ .b', errors: errors..clear());
expect(errors.isEmpty, true, reason: errors.toString());
- expect(compactOuptut(selectorAst), '.a >>> .b');
+ expect(compactOuptut(selectorAst), '.a /deep/ .b');
selectorAst = selector('.x >>> .y', errors: errors..clear());
expect(errors.isEmpty, true, reason: errors.toString());