@@ -70,11 +70,10 @@ def vdom_to_html(value: VdomDict) -> str:
70
70
"""
71
71
temp_root = etree .Element ("__temp__" )
72
72
_add_vdom_to_etree (temp_root , value )
73
- return (
74
- cast (bytes , tostring (temp_root )).decode ()
75
- # strip out temp root <__temp__> element
76
- [10 :- 11 ]
77
- )
73
+ html = cast (bytes , tostring (temp_root )).decode ()
74
+
75
+ # strip out temp root <__temp__> element
76
+ return html [10 :- 11 ]
78
77
79
78
80
79
def html_to_vdom (
@@ -201,7 +200,7 @@ def _add_vdom_to_etree(parent: etree._Element, vdom: VdomDict | dict[str, Any])
201
200
if tag :
202
201
element = etree .SubElement (parent , tag )
203
202
element .attrib .update (
204
- _vdom_to_html_attr (k , v ) for k , v in vdom .get ("attributes" , {}).items ()
203
+ _vdom_attr_to_html_str (k , v ) for k , v in vdom .get ("attributes" , {}).items ()
205
204
)
206
205
else :
207
206
element = parent
@@ -283,7 +282,7 @@ def _hypen_to_camel_case(string: str) -> str:
283
282
}
284
283
285
284
286
- def _vdom_to_html_attr (key : str , value : Any ) -> tuple [str , str ]:
285
+ def _vdom_attr_to_html_str (key : str , value : Any ) -> tuple [str , str ]:
287
286
if key == "style" :
288
287
if isinstance (value , dict ):
289
288
value = ";" .join (
@@ -292,7 +291,7 @@ def _vdom_to_html_attr(key: str, value: Any) -> tuple[str, str]:
292
291
f"{ _CAMEL_CASE_SUB_PATTERN .sub ('-' , k ).lower ()} :{ v } "
293
292
for k , v in value .items ()
294
293
)
295
- elif key .startswith ("data" ):
294
+ elif key .startswith ("data" ) or key . startswith ( "aria" ) :
296
295
# Handle data-* attribute names
297
296
key = _CAMEL_CASE_SUB_PATTERN .sub ("-" , key )
298
297
else :
0 commit comments