Skip to content

Commit b4f380c

Browse files
committed
minor improvements
1 parent c0e1248 commit b4f380c

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/idom/utils.py

+7-8
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,10 @@ def vdom_to_html(value: VdomDict) -> str:
7070
"""
7171
temp_root = etree.Element("__temp__")
7272
_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]
7877

7978

8079
def html_to_vdom(
@@ -201,7 +200,7 @@ def _add_vdom_to_etree(parent: etree._Element, vdom: VdomDict | dict[str, Any])
201200
if tag:
202201
element = etree.SubElement(parent, tag)
203202
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()
205204
)
206205
else:
207206
element = parent
@@ -283,7 +282,7 @@ def _hypen_to_camel_case(string: str) -> str:
283282
}
284283

285284

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]:
287286
if key == "style":
288287
if isinstance(value, dict):
289288
value = ";".join(
@@ -292,7 +291,7 @@ def _vdom_to_html_attr(key: str, value: Any) -> tuple[str, str]:
292291
f"{_CAMEL_CASE_SUB_PATTERN.sub('-', k).lower()}:{v}"
293292
for k, v in value.items()
294293
)
295-
elif key.startswith("data"):
294+
elif key.startswith("data") or key.startswith("aria"):
296295
# Handle data-* attribute names
297296
key = _CAMEL_CASE_SUB_PATTERN.sub("-", key)
298297
else:

0 commit comments

Comments
 (0)