@@ -20,6 +20,7 @@ where
2020 listeners: Listeners,
2121 attributes: Attributes,
2222 children: Children,
23+ namespace: Option<&'a str>,
2324}
2425
2526impl<'a>
@@ -60,6 +61,7 @@ impl<'a>
6061 listeners: bumpalo::collections::Vec::new_in(bump),
6162 attributes: bumpalo::collections::Vec::new_in(bump),
6263 children: bumpalo::collections::Vec::new_in(bump),
64+ namespace: None,
6365 }
6466 }
6567}
@@ -108,6 +110,7 @@ where
108110 listeners,
109111 attributes: self.attributes,
110112 children: self.children,
113+ namespace: self.namespace,
111114 }
112115 }
113116
@@ -145,6 +148,7 @@ where
145148 listeners: self.listeners,
146149 attributes,
147150 children: self.children,
151+ namespace: self.namespace,
148152 }
149153 }
150154
@@ -182,6 +186,33 @@ where
182186 listeners: self.listeners,
183187 attributes: self.attributes,
184188 children,
189+ namespace: self.namespace,
190+ }
191+ }
192+
193+ /// Set the namespace for this element.
194+ ///
195+ /// # Example
196+ ///
197+ /// ```no_run
198+ /// use dodrio::{builder::*, bumpalo::Bump};
199+ ///
200+ /// let b = Bump::new();
201+ ///
202+ /// // Create a `<td>` tag with an xhtml namespace
203+ /// let my_div = td(&b)
204+ /// .namespace(Some("http://www.w3.org/1999/xhtml"))
205+ /// .finish();
206+ /// ```
207+ #[inline]
208+ pub fn namespace(self, namespace: Option<&'a str>) -> Self {
209+ ElementBuilder {
210+ bump: self.bump,
211+ tag_name: self.tag_name,
212+ listeners: self.listeners,
213+ attributes: self.attributes,
214+ children: self.children,
215+ namespace,
185216 }
186217 }
187218
@@ -208,6 +239,7 @@ where
208239 self.listeners,
209240 self.attributes,
210241 self.children,
242+ self.namespace,
211243 )
212244 }
213245}
@@ -357,6 +389,26 @@ macro_rules! builder_constructors {
357389 ElementBuilder::new(bump, stringify!($name))
358390 }
359391 )*
392+ };
393+ ( $(
394+ $(#[$attr:meta])*
395+ $name:ident <> $namespace:tt;
396+ )* ) => {
397+ $(
398+ $(#[$attr])*
399+ #[inline]
400+ pub fn $name<'a>(
401+ bump: &'a Bump,
402+ ) -> ElementBuilder<
403+ 'a,
404+ bumpalo::collections::Vec<'a, Listener<'a>>,
405+ bumpalo::collections::Vec<'a, Attribute<'a>>,
406+ bumpalo::collections::Vec<'a, Node<'a>>,
407+ > {
408+ let builder = ElementBuilder::new(bump, stringify!($name));
409+ builder.namespace(Some($namespace))
410+ }
411+ )*
360412 }
361413}
362414
@@ -861,6 +913,43 @@ builder_constructors! {
861913 template;
862914}
863915
916+builder_constructors! {
917+ // SVG components
918+
919+ /// Build a
920+ /// [`<svg>`](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/svg)
921+ /// element.
922+ svg <> "http://www.w3.org/2000/svg" ;
923+ /// Build a
924+ /// [`<path>`](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/path)
925+ /// element.
926+ path <> "http://www.w3.org/2000/svg";
927+ /// Build a
928+ /// [`<circle>`](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/circle)
929+ /// element.
930+ circle <> "http://www.w3.org/2000/svg";
931+ /// Build a
932+ /// [`<ellipse>`](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/ellipse)
933+ /// element.
934+ ellipse <> "http://www.w3.org/2000/svg";
935+ /// Build a
936+ /// [`<line>`](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/line)
937+ /// element.
938+ line <> "http://www.w3.org/2000/svg";
939+ /// Build a
940+ /// [`<polygon>`](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/polygon)
941+ /// element.
942+ polygon <> "http://www.w3.org/2000/svg";
943+ /// Build a
944+ /// [`<polyline>`](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/polyline)
945+ /// element.
946+ polyline <> "http://www.w3.org/2000/svg";
947+ /// Build a
948+ /// [`<rect>`](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/rect)
949+ /// element.
950+ rect <> "http://www.w3.org/2000/svg";
951+}
952+
864953/// Construct a text node.
865954///
866955/// This is `dodrio`'s virtual DOM equivalent of `document.createTextNode`.