From 81c8dab8a17e389be9390260e8e22b5c0ef4df4c Mon Sep 17 00:00:00 2001 From: Simon Potter Date: Thu, 11 Jul 2019 19:23:43 +1200 Subject: [PATCH] Parse |ident as ident. No longer an error. --- cssselect/parser.py | 3 +++ tests/test_cssselect.py | 1 + 2 files changed, 4 insertions(+) diff --git a/cssselect/parser.py b/cssselect/parser.py index 3be71bb..b96d26a 100644 --- a/cssselect/parser.py +++ b/cssselect/parser.py @@ -430,6 +430,9 @@ def parse_simple_selector(stream, inside_negation=False): elif peek == ('DELIM', '.'): stream.next() result = Class(result, stream.next_ident()) + elif peek == ('DELIM', '|'): + stream.next() + result = Element(None, stream.next_ident()) elif peek == ('DELIM', '['): stream.next() result = parse_attrib(result, stream) diff --git a/tests/test_cssselect.py b/tests/test_cssselect.py index 8b562da..d2432ab 100644 --- a/tests/test_cssselect.py +++ b/tests/test_cssselect.py @@ -81,6 +81,7 @@ def parse_many(first, *others): assert parse_many('*') == ['Element[*]'] assert parse_many('*|*') == ['Element[*]'] assert parse_many('*|foo') == ['Element[foo]'] + assert parse_many('|foo') == ['Element[foo]'] assert parse_many('foo|*') == ['Element[foo|*]'] assert parse_many('foo|bar') == ['Element[foo|bar]'] # This will never match, but it is valid: