diff --git a/src/reactpy_django/forms/transforms.py b/src/reactpy_django/forms/transforms.py index 4eadbd83..1a757b77 100644 --- a/src/reactpy_django/forms/transforms.py +++ b/src/reactpy_django/forms/transforms.py @@ -74,14 +74,14 @@ def infer_key_from_attributes(vdom_tree: VdomDict) -> VdomDict: attributes = vdom_tree.get("attributes", {}) # Infer 'key' from 'id' - _id = attributes.get("id") + key = attributes.get("id") # Fallback: Infer 'key' from 'name' - if not _id and vdom_tree["tagName"] in {"input", "select", "textarea"}: - _id = attributes.get("name") + if not key and vdom_tree["tagName"] in {"input", "select", "textarea"}: + key = attributes.get("name") - if _id: - vdom_tree["key"] = _id + if key: + vdom_tree["key"] = key return vdom_tree @@ -479,7 +479,8 @@ def _do_nothing_event(*args, **kwargs): + SCRIPT_PROPS ) -# lowercase the prop name as the key, and have values be the original react prop name +# Old Prop (Key) : New Prop (Value) +# Also includes some special cases like 'class' -> 'className' REACT_PROP_SUBSTITUTIONS = {prop.lower(): prop for prop in KNOWN_REACT_PROPS} | { "for": "htmlFor", "class": "className", diff --git a/src/reactpy_django/utils.py b/src/reactpy_django/utils.py index 888b0cf7..1ea4f0ea 100644 --- a/src/reactpy_django/utils.py +++ b/src/reactpy_django/utils.py @@ -1,3 +1,5 @@ +"""Generic functions that are used throughout the ReactPy Django package.""" + from __future__ import annotations import contextlib