Add extra check for line-style parsing

Fixes #385.
This commit is contained in:
Arjan Molenaar
2020-08-05 23:14:30 +02:00
parent ce6df837d0
commit 83a9a5a564
2 changed files with 11 additions and 1 deletions

View File

@ -164,7 +164,7 @@ def parse_enum(prop, value):
def parse_line_style(prop, value) -> float:
if value == "sloppy":
return 0.5
elif isinstance(value, tuple):
elif isinstance(value, tuple) and len(value) == 2:
style, factor = value
if style == "sloppy":
if not isinstance(factor, number):

View File

@ -207,3 +207,13 @@ def test_line_style(css_value, result):
props = compiled_style_sheet.match(Node("mytype"))
assert props.get("line-style") == result
def test_broken_line_style():
# diagram css is missing the closing bracket
css = "diagram { line-style: sloppy * { }"
compiled_style_sheet = CompiledStyleSheet(css)
props = compiled_style_sheet.match(Node("mytype"))
assert props.get("line-style") is None