Skip to content

Commit

Permalink
variable name and docstring cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Archmonger committed Dec 19, 2024
1 parent 6238383 commit 207cf19
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/reactpy_django/forms/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions src/reactpy_django/utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""Generic functions that are used throughout the ReactPy Django package."""

from __future__ import annotations

import contextlib
Expand Down

0 comments on commit 207cf19

Please sign in to comment.