Skip to content

Commit 18d7282

Browse files
committed
Use new fragment syntax
1 parent 15ea86e commit 18d7282

File tree

8 files changed

+15
-16
lines changed

8 files changed

+15
-16
lines changed

src/reactpy/_html.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,6 @@ class HtmlConstructor:
278278
__cache__: ClassVar[dict[str, VdomDictConstructor]] = {
279279
"script": custom_vdom_constructor(_script),
280280
"fragment": custom_vdom_constructor(_fragment),
281-
"_": custom_vdom_constructor(_fragment),
282281
}
283282

284283
def __getattr__(self, value: str) -> VdomDictConstructor:

src/reactpy/backend/_common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def vdom_head_elements_to_html(head: Sequence[VdomDict] | VdomDict | str) -> str
109109
head = cast(VdomDict, {**head, "tagName": ""})
110110
return vdom_to_html(head)
111111
else:
112-
return vdom_to_html(html._(*head))
112+
return vdom_to_html(html.fragment(*head))
113113

114114

115115
@dataclass

tests/test_backend/test_common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def test_catch_unsafe_relative_path_traversal(tmp_path, bad_path):
5151
'<meta charset="utf-8"><title>example</title>',
5252
),
5353
(
54-
html._(
54+
html.fragment(
5555
html.meta({"charset": "utf-8"}),
5656
html.title("example"),
5757
),

tests/test_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ async def test_automatic_reconnect(browser: Browser):
2323
@reactpy.component
2424
def SomeComponent():
2525
count, incr_count = use_counter(0)
26-
return reactpy.html._(
26+
return reactpy.html.fragment(
2727
reactpy.html.p({"data_count": count, "id": "count"}, "count", count),
2828
reactpy.html.button(
2929
{"on_click": lambda e: incr_count(), "id": "incr"}, "incr"

tests/test_core/test_hooks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -979,7 +979,7 @@ async def test_context_values_are_scoped():
979979

980980
@reactpy.component
981981
def Parent():
982-
return html._(
982+
return html.fragment(
983983
Context(Context(Child1(), value=1), value="something-else"),
984984
Context(Child2(), value=2),
985985
)

tests/test_core/test_layout.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,7 +1224,7 @@ def colorize(event):
12241224
@component
12251225
def App():
12261226
items = use_state(["A", "B", "C"])
1227-
return html._([Item(item, items, key=item) for item in items.value])
1227+
return html.fragment([Item(item, items, key=item) for item in items.value])
12281228

12291229
async with layout_runner(reactpy.Layout(App())) as runner:
12301230
tree = await runner.render()
@@ -1265,7 +1265,7 @@ async def test_async_renders(async_rendering):
12651265

12661266
@component
12671267
def outer():
1268-
return html._(child_1(), child_2())
1268+
return html.fragment(child_1(), child_2())
12691269

12701270
@component
12711271
@child_1_hook.capture

tests/test_html.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@ def test_script_has_no_event_handlers():
8888

8989

9090
def test_simple_fragment():
91-
assert html._() == {"tagName": ""}
92-
assert html._(1, 2, 3) == {"tagName": "", "children": [1, 2, 3]}
93-
assert html._({"key": "something"}) == {"tagName": "", "key": "something"}
94-
assert html._({"key": "something"}, 1, 2, 3) == {
91+
assert html.fragment() == {"tagName": ""}
92+
assert html.fragment(1, 2, 3) == {"tagName": "", "children": [1, 2, 3]}
93+
assert html.fragment({"key": "something"}) == {"tagName": "", "key": "something"}
94+
assert html.fragment({"key": "something"}, 1, 2, 3) == {
9595
"tagName": "",
9696
"key": "something",
9797
"children": [1, 2, 3],
@@ -100,4 +100,4 @@ def test_simple_fragment():
100100

101101
def test_fragment_can_have_no_attributes():
102102
with pytest.raises(TypeError, match="Fragments cannot have attributes"):
103-
html._({"some_attribute": 1})
103+
html.fragment({"some_attribute": 1})

tests/test_utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,11 +215,11 @@ def test_del_html_body_transform():
215215
"<button></button>",
216216
),
217217
(
218-
html._("hello ", html._("world")),
218+
html.fragment("hello ", html.fragment("world")),
219219
"hello world",
220220
),
221221
(
222-
html._(html.div("hello"), html._("world")),
222+
html.fragment(html.div("hello"), html.fragment("world")),
223223
"<div>hello</div>world",
224224
),
225225
(
@@ -231,15 +231,15 @@ def test_del_html_body_transform():
231231
'<div style="background-color:blue;margin-left:10px"></div>',
232232
),
233233
(
234-
html._(
234+
html.fragment(
235235
html.div("hello"),
236236
html.a({"href": "https://example.com"}, "example"),
237237
),
238238
'<div>hello</div><a href="https://example.com">example</a>',
239239
),
240240
(
241241
html.div(
242-
html._(
242+
html.fragment(
243243
html.div("hello"),
244244
html.a({"href": "https://example.com"}, "example"),
245245
),

0 commit comments

Comments
 (0)