Skip to content

Commit

Permalink
Add key to new_vtag method
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielleHuisman committed Aug 21, 2024
1 parent 4c6e549 commit 9d5ea44
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions packages/yew-attrs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,20 @@
//! #[derive(PartialEq, Properties)]
//! struct ButtonProps {
//! #[prop_or_default]
//! pub node_ref: NodeRef,
//! #[prop_or_default]
//! pub attrs: Attrs,
//! #[prop_or_default]
//! pub children: Html,
//! }
//!
//! #[function_component]
//! fn Button(props: &ButtonProps) -> Html {
//! VTag::__new_other(
//! "button".into(),
//! Default::default(),
//! Default::default(),
//! props.attrs.attributes.clone(),
//! props.attrs.listeners.clone(),
//! props.children.clone(),
//! )
//! .into()
//! props
//! .attrs
//! .clone()
//! .new_vtag("button", props.node_ref.clone(), Default::default(), props.children.clone())
//! .into()
//! }
//!
//! #[function_component]
Expand All @@ -43,7 +41,7 @@ pub use yew_attrs_macro::attrs;
use indexmap::IndexMap;
use thiserror::Error;
use yew::{
virtual_dom::{ApplyAttributeAs, Attributes, Listeners, VTag},
virtual_dom::{ApplyAttributeAs, Attributes, Key, Listeners, VTag},
AttrValue, Html, NodeRef,
};

Expand Down Expand Up @@ -83,7 +81,7 @@ impl Attrs {
}

/// Create a new [`VTag`] using the attributes and listeners from this [`Attrs`].
pub fn new_vtag(self, tag: &str, node_ref: NodeRef, children: Html) -> VTag {
pub fn new_vtag(self, tag: &str, node_ref: NodeRef, key: Option<Key>, children: Html) -> VTag {
match tag {
"input" | "INPUT" => {
let (value, checked) = {
Expand All @@ -101,7 +99,7 @@ impl Attrs {
value.cloned(),
checked.map(|_| true),
node_ref,
Default::default(),
key,
self.attributes,
self.listeners,
)
Expand All @@ -118,15 +116,15 @@ impl Attrs {
VTag::__new_textarea(
value.cloned(),
node_ref,
Default::default(),
key,
self.attributes,
self.listeners,
)
}
tag => VTag::__new_other(
tag.to_string().into(),
node_ref.clone(),
Default::default(),
key,
self.attributes,
self.listeners,
children,
Expand Down

0 comments on commit 9d5ea44

Please sign in to comment.