@@ -22,6 +22,48 @@ where
22 children: Children,
22 children: Children,
28+ bumpalo::collections::Vec<'a, Listener<'a>>,
29+ bumpalo::collections::Vec<'a, Attribute<'a>>,
30+ bumpalo::collections::Vec<'a, Node<'a>>,
33+ /// Create a new `ElementBuilder` for an element with the given tag name.
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.
43+ /// use dodrio::{builder::*, bumpalo::Bump};
45+ /// let b = Bump::new();
47+ /// let tag_name = if flip_coin() {
53+ /// let my_element_builder = ElementBuilder::new(&b, tag_name);
54+ /// # fn flip_coin() -> bool { true }
56+ pub fn new(bump: &'a Bump, tag_name: &'a str) -> Self {
60+ listeners: bumpalo::collections::Vec::new_in(bump),
61+ attributes: bumpalo::collections::Vec::new_in(bump),
62+ children: bumpalo::collections::Vec::new_in(bump),
25impl<'a, Listeners, Attributes, Children> ElementBuilder<'a, Listeners, Attributes, Children>
67impl<'a, Listeners, Attributes, Children> ElementBuilder<'a, Listeners, Attributes, Children>
27 Listeners: 'a + AsRef<[Listener<'a>]>,
69 Listeners: 'a + AsRef<[Listener<'a>]>,
@@ -312,13 +354,7 @@ macro_rules! builder_constructors {
312 bumpalo::collections::Vec<'a, Attribute<'a>>,
354 bumpalo::collections::Vec<'a, Attribute<'a>>,
313 bumpalo::collections::Vec<'a, Node<'a>>,
355 bumpalo::collections::Vec<'a, Node<'a>>,
315− ElementBuilder {
357+ ElementBuilder::new(bump, stringify!($name))
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),