@@ -22,6 +22,48 @@ where
2222 children: Children,
2323}
2424
25+impl<'a>
26+ ElementBuilder<
27+ 'a,
28+ bumpalo::collections::Vec<'a, Listener<'a>>,
29+ bumpalo::collections::Vec<'a, Attribute<'a>>,
30+ bumpalo::collections::Vec<'a, Node<'a>>,
31+ >
32+{
33+ /// Create a new `ElementBuilder` for an element with the given tag name.
34+ ///
35+ /// In general, only use this constructor if the tag is dynamic (i.e. you
36+ /// might build a `<div>` or you might build a `<span>` and you don't know
37+ /// until runtime). Prefer using the tag-specific constructors instead:
38+ /// `div(bump)` or `span(bump)`, etc.
39+ ///
40+ /// # Example
41+ ///
42+ /// ```
43+ /// use dodrio::{builder::*, bumpalo::Bump};
44+ ///
45+ /// let b = Bump::new();
46+ ///
47+ /// let tag_name = if flip_coin() {
48+ /// "div"
49+ /// } else {
50+ /// "span"
51+ /// };
52+ ///
53+ /// let my_element_builder = ElementBuilder::new(&b, tag_name);
54+ /// # fn flip_coin() -> bool { true }
55+ /// ```
56+ pub fn new(bump: &'a Bump, tag_name: &'a str) -> Self {
57+ ElementBuilder {
58+ bump,
59+ tag_name,
60+ listeners: bumpalo::collections::Vec::new_in(bump),
61+ attributes: bumpalo::collections::Vec::new_in(bump),
62+ children: bumpalo::collections::Vec::new_in(bump),
63+ }
64+ }
65+}
66+
2567impl<'a, Listeners, Attributes, Children> ElementBuilder<'a, Listeners, Attributes, Children>
2668where
2769 Listeners: 'a + AsRef<[Listener<'a>]>,
@@ -312,13 +354,7 @@ macro_rules! builder_constructors {
312354 bumpalo::collections::Vec<'a, Attribute<'a>>,
313355 bumpalo::collections::Vec<'a, Node<'a>>,
314356 > {
315− ElementBuilder {
316− bump,
317− tag_name: stringify!($name),
318− listeners: bumpalo::collections::Vec::new_in(bump),
319− attributes: bumpalo::collections::Vec::new_in(bump),
320− children: bumpalo::collections::Vec::new_in(bump),
321− }
357+ ElementBuilder::new(bump, stringify!($name))
322358 }
323359 )*
324360 }