File tree 4 files changed +35
-1
lines changed
4 files changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -1016,4 +1016,25 @@ export const tests: [
1016
1016
] ,
1017
1017
"case-sensitive attribute selector" ,
1018
1018
] ,
1019
+ [
1020
+ "foo || bar" ,
1021
+ [
1022
+ [
1023
+ {
1024
+ name : "foo" ,
1025
+ namespace : null ,
1026
+ type : SelectorType . Tag ,
1027
+ } ,
1028
+ {
1029
+ type : SelectorType . ColumnCombinator ,
1030
+ } ,
1031
+ {
1032
+ name : "bar" ,
1033
+ namespace : null ,
1034
+ type : SelectorType . Tag ,
1035
+ } ,
1036
+ ] ,
1037
+ ] ,
1038
+ "column combinator" ,
1039
+ ] ,
1019
1040
] ;
Original file line number Diff line number Diff line change @@ -137,6 +137,7 @@ export function isTraversal(selector: Selector): selector is Traversal {
137
137
case SelectorType . Descendant :
138
138
case SelectorType . Parent :
139
139
case SelectorType . Sibling :
140
+ case SelectorType . ColumnCombinator :
140
141
return true ;
141
142
default :
142
143
return false ;
@@ -616,6 +617,14 @@ function parseSelector(
616
617
name = "*" ;
617
618
} else if ( firstChar === CharCode . Pipe ) {
618
619
name = "" ;
620
+
621
+ if (
622
+ selector . charCodeAt ( selectorIndex + 1 ) === CharCode . Pipe
623
+ ) {
624
+ addTraversal ( SelectorType . ColumnCombinator ) ;
625
+ stripWhitespace ( 2 ) ;
626
+ break ;
627
+ }
619
628
} else if ( reName . test ( selector . slice ( selectorIndex ) ) ) {
620
629
name = getName ( 0 ) ;
621
630
} else {
Original file line number Diff line number Diff line change @@ -32,6 +32,8 @@ function stringifyToken(token: Selector): string {
32
32
return " + " ;
33
33
case SelectorType . Descendant :
34
34
return " " ;
35
+ case SelectorType . ColumnCombinator :
36
+ return " || " ;
35
37
case SelectorType . Universal :
36
38
return `${ getNamespace ( token . namespace ) } *` ;
37
39
Original file line number Diff line number Diff line change @@ -42,6 +42,7 @@ export enum SelectorType {
42
42
Descendant = "descendant" ,
43
43
Parent = "parent" ,
44
44
Sibling = "sibling" ,
45
+ ColumnCombinator = "column-combinator" ,
45
46
}
46
47
47
48
export interface AttributeSelector {
@@ -97,4 +98,5 @@ export type TraversalType =
97
98
| SelectorType . Child
98
99
| SelectorType . Descendant
99
100
| SelectorType . Parent
100
- | SelectorType . Sibling ;
101
+ | SelectorType . Sibling
102
+ | SelectorType . ColumnCombinator ;
You can’t perform that action at this time.
0 commit comments