Skip to content

Commit 0647781

Browse files
committed
fix data-* and aria-* attribute name conversion
1 parent bd87407 commit 0647781

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/client/packages/idom-client-react/src/element-utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ function normalizeAttribute([key, value]) {
6464
key.startsWith("aria_") ||
6565
DASHED_HTML_ATTRS.includes(key)
6666
) {
67-
normKey = key.replace("_", "-");
67+
normKey = key.split("_").join("-");
6868
} else {
6969
normKey = snakeToCamel(key);
7070
}

tests/test_client.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,21 @@ async def handle_change(event):
132132
await inp.type("hello", delay=DEFAULT_TYPE_DELAY)
133133

134134
assert (await inp.evaluate("node => node.value")) == "hello"
135+
136+
137+
async def test_data_and_aria_attribute_naming(display: DisplayFixture):
138+
@idom.component
139+
def SomeComponent():
140+
return idom.html.h1(
141+
"see attributes",
142+
id="title",
143+
data_some_thing="some data",
144+
aria_description="some title",
145+
)
146+
147+
await display.show(SomeComponent)
148+
149+
title = await display.page.wait_for_selector("#title")
150+
151+
assert await title.get_attribute("data-some-thing") == "some data"
152+
assert await title.get_attribute("aria-description") == "some title"

0 commit comments

Comments
 (0)