Skip to content

Commit d457f61

Browse files
authored
Alternate solution for expensive any on attributes
Since "key" is the only allowed attribute, I just pop that out before checking if anything is left in attributes, and if so, the error is raised.
1 parent 7591d1f commit d457f61

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/reactpy/_html.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ def _fragment(
104104
event_handlers: EventHandlerDict,
105105
) -> VdomDict:
106106
"""An HTML fragment - this element will not appear in the DOM"""
107-
if (attributes and any(a != "key" for a in attributes)) or event_handlers:
107+
attributes.pop("key", None)
108+
if attributes or event_handlers:
108109
msg = "Fragments cannot have attributes besides 'key'"
109110
raise TypeError(msg)
110111
model = VdomDict(tagName="")

0 commit comments

Comments
 (0)