From 89d893be2a89572fcde25c7fc270253e00572961 Mon Sep 17 00:00:00 2001 From: Philipp Mildenberger Date: Mon, 7 Aug 2023 01:21:33 +0200 Subject: [PATCH] Allow all `Into` instead of just `Into` for the untyped `Element::attr` method for more convenient use with untyped attrs --- crates/xilem_html/src/element/elements.rs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/crates/xilem_html/src/element/elements.rs b/crates/xilem_html/src/element/elements.rs index a02aa007d..73cbd9840 100644 --- a/crates/xilem_html/src/element/elements.rs +++ b/crates/xilem_html/src/element/elements.rs @@ -477,10 +477,6 @@ impl From<&'static str> for AttributeValue { type Attrs = VecMap; impl Attrs { - fn insert_untyped(&mut self, name: impl Into, value: impl Into) { - self.insert(name.into(), AttributeValue::String(value.into())); - } - fn insert_attr(&mut self, name: impl Into, value: impl Into) { self.insert(name.into(), value.into()); } @@ -929,8 +925,8 @@ pub trait Element: Node + crate::view::View { // TODO should this be in its own trait? (it doesn't have much to do with the DOM Node interface) fn raw_attrs(&self) -> &Attrs; // TODO should this be in Node? - fn attr, V: Into>(self, key: K, value: V) -> Self; - fn set_attr, V: Into>(&mut self, key: K, value: V); + fn attr, V: Into>(self, key: K, value: V) -> Self; + fn set_attr, V: Into>(&mut self, key: K, value: V); // TODO generate all this event listener boilerplate with macros fn on_click(self, handler: EH) -> Self @@ -1054,17 +1050,17 @@ macro_rules! impl_element { &self.attrs } - fn attr, V: Into>( + fn attr, V: Into>( mut self, key: K, value: V, ) -> $ty_name { - self.attrs.insert_untyped(key, value); + self.attrs.insert_attr(key, value); self } - fn set_attr, V: Into>(&mut self, key: K, value: V) { - self.attrs.insert_untyped(key, value); + fn set_attr, V: Into>(&mut self, key: K, value: V) { + self.attrs.insert_attr(key, value); } fn on_click(self, handler: EH) -> $ty_name