Skip to content

Commit d446161

Browse files
committed
Set default attributes in transforms
1 parent bd58a1b commit d446161

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/reactpy_django/forms/transforms.py

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def convert_textarea_children_to_prop(vdom_tree: VdomDict) -> VdomDict:
2323
"""Transformation that converts the text content of a <textarea> to the 'value' prop."""
2424
# If the current tag is <textarea>, move the text content to the 'value' prop.
2525
if vdom_tree["tagName"] == "textarea" and "children" in vdom_tree and vdom_tree["children"]:
26+
vdom_tree.setdefault("attributes", {})
2627
text_content = vdom_tree.pop("children")
2728
text_content = "".join([child for child in text_content if isinstance(child, str)])
2829
default_value = vdom_tree["attributes"].pop("defaultValue", "")
@@ -36,6 +37,7 @@ def set_value_prop_on_select_element(vdom_tree: VdomDict) -> VdomDict:
3637
# If the current tag is <select>, remove 'selected' prop from any <option> children and
3738
# instead set the 'value' prop on the <select> tag.
3839
if vdom_tree["tagName"] == "select" and "children" in vdom_tree:
40+
vdom_tree.setdefault("attributes", {})
3941
selected_options = _find_selected_options(vdom_tree)
4042
multiple_choice = vdom_tree["attributes"]["multiple"] = bool(vdom_tree["attributes"].get("multiple"))
4143
if selected_options and not multiple_choice:

0 commit comments

Comments
 (0)