diff --git a/packages/yew-macro/src/html_tree/html_element.rs b/packages/yew-macro/src/html_tree/html_element.rs index c1ef4e72c6a..19d814ed4be 100644 --- a/packages/yew-macro/src/html_tree/html_element.rs +++ b/packages/yew-macro/src/html_tree/html_element.rs @@ -641,6 +641,9 @@ impl Parse for HtmlElementOpen { if let Some(attr) = props.value.take() { props.attributes.push(attr); } + if let Some(attr) = props.checked.take() { + props.attributes.push(attr); + } } } } diff --git a/packages/yew/src/dom_bundle/btag/mod.rs b/packages/yew/src/dom_bundle/btag/mod.rs index fca3b521344..c590d6be6c5 100644 --- a/packages/yew/src/dom_bundle/btag/mod.rs +++ b/packages/yew/src/dom_bundle/btag/mod.rs @@ -1096,6 +1096,7 @@ mod layout_tests { #[cfg(test)] mod tests_without_browser { use crate::html; + use crate::virtual_dom::VNode; #[test] fn html_if_bool() { @@ -1268,4 +1269,32 @@ mod tests_without_browser { html! {
<>
}, ); } + + #[test] + fn input_checked_stays_there() { + let tag = html! { + + }; + match tag { + VNode::VTag(tag) => { + assert_eq!(tag.checked(), Some(true)); + } + _ => unreachable!(), + } + } + #[test] + fn non_input_checked_stays_there() { + let tag = html! { + + }; + match tag { + VNode::VTag(tag) => { + assert_eq!( + tag.attributes.iter().find(|(k, _)| *k == "checked"), + Some(("checked", "true")) + ); + } + _ => unreachable!(), + } + } }