From 503570e59e010215d22993d11cb61fa801b3b752 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20B=C3=B6hm?= <188768+fb55@users.noreply.github.com> Date: Mon, 27 Dec 2021 11:45:51 +0100 Subject: [PATCH] fix(parse): Fix parsing column combinators after tag names --- src/__fixtures__/tests.ts | 21 +++++++++++++++++++++ src/parse.ts | 5 ++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/__fixtures__/tests.ts b/src/__fixtures__/tests.ts index 388fdc5e..ec788647 100644 --- a/src/__fixtures__/tests.ts +++ b/src/__fixtures__/tests.ts @@ -972,4 +972,25 @@ export const tests: [ ], "column combinator", ], + [ + "foo||bar", + [ + [ + { + name: "foo", + namespace: null, + type: SelectorType.Tag, + }, + { + type: SelectorType.ColumnCombinator, + }, + { + name: "bar", + namespace: null, + type: SelectorType.Tag, + }, + ], + ], + "column combinator without whitespace", + ], ]; diff --git a/src/parse.ts b/src/parse.ts index 03534374..6161152b 100644 --- a/src/parse.ts +++ b/src/parse.ts @@ -564,7 +564,10 @@ function parseSelector( break loop; } - if (selector.charCodeAt(selectorIndex) === CharCode.Pipe) { + if ( + selector.charCodeAt(selectorIndex) === CharCode.Pipe && + selector.charCodeAt(selectorIndex + 1) !== CharCode.Pipe + ) { namespace = name; if ( selector.charCodeAt(selectorIndex + 1) ===