Invalid pseudo selectors (#2445)

* token error

* error on bad pseudo selectors
This commit is contained in:
Will McGugan
2023-05-01 16:22:35 +01:00
committed by GitHub
parent 08de9a0fca
commit 20a1612361
4 changed files with 82 additions and 31 deletions

View File

@@ -140,52 +140,52 @@ A1
/**********************************************************************/
A:foo {}
A:foo:bar {}
A:focus {}
A:focus:hover {}
A
:foo {}
:focus {}
A
:foo:bar {}
:focus:hover {}
A
:foo
:bar {}
A:foo-bar {}
:focus
:hover {}
A:enabled {}
A
:foo-bar {}
:enabled {}
A :foo {}
A :foo :bar {}
A :foo-bar {}
A :focus {}
A :focus :hover {}
A :enabled {}
.A:foo {}
.A:foo:bar {}
.A:focus {}
.A:focus:hover {}
.A
:foo {}
:focus {}
.A
:foo:bar {}
:focus:hover {}
.A
:foo
:bar {}
.A:foo-bar {}
:focus
:hover {}
.A:enabled {}
.A
:foo-bar {}
:enabled {}
#A:foo {}
#A:foo:bar {}
#A:focus {}
#A:focus:hover {}
#A
:foo {}
:focus {}
#A
:foo:bar {}
:focus:hover {}
#A
:foo
:bar {}
#A:foo-bar {}
:focus
:hover {}
#A:enabled {}
#A
:foo-bar {}
:enabled {}
A1.A1.A1:foo {}
A1.A1#A1:foo {}
A1:foo.A1:foo#A1:foo {}
A1.A1.A1:focus {}
A1.A1#A1:focus {}
A1:focus.A1:focus#A1:focus {}
/**********************************************************************/

View File

@@ -1226,3 +1226,21 @@ class TestTypeNames:
stylesheet.add_source(f"StartType {separator} 1TestType {{}}")
with pytest.raises(TokenError):
stylesheet.parse()
def test_parse_bad_psuedo_selector():
"""Check unknown selector raises a token error."""
bad_selector = """\
Widget:foo{
border: red;
}
"""
stylesheet = Stylesheet()
stylesheet.add_source(bad_selector, "foo")
with pytest.raises(TokenError) as error:
stylesheet.parse()
assert error.value.start == (0, 6)