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: