diff --git a/conftest.py b/conftest.py new file mode 100644 index 0000000..5729d8d --- /dev/null +++ b/conftest.py @@ -0,0 +1,2 @@ +# used by pytest to test against the local copy of dominate +# (this file is important even though it is empty) diff --git a/dominate/dom_tag.py b/dominate/dom_tag.py index 88b4716..50ac5e1 100644 --- a/dominate/dom_tag.py +++ b/dominate/dom_tag.py @@ -401,7 +401,8 @@ def clean_attribute(attribute): attribute = attribute[1:] # Workaround for dash - if attribute in set(['http_equiv']) or attribute.startswith('data_'): + special_prefix = any([attribute.startswith(x) for x in ('data_', 'aria_')]) + if attribute in set(['http_equiv']) or special_prefix: attribute = attribute.replace('_', '-').lower() # Workaround for colon diff --git a/tests/test_html.py b/tests/test_html.py index f71f8e4..dff9aa2 100644 --- a/tests/test_html.py +++ b/tests/test_html.py @@ -208,6 +208,12 @@ def test_attributes(): attr(id='moo') +def test_attribute_dashes(): + # fix issue #118 (https://github.com/Knio/dominate/issues/118) + expected = '
' + assert div(data_a_b_c='foo', data_page_size='123', aria_foo='bar').render() == expected + + def test_lazy(): from dominate import util executed = [False]