on master help sign in
Make builder constructors generic over `B: Into<&'bump Bump>`

This makes using them with a `RenderContext` a bit more ergonomic.

commit4e428e0a9f88e09d5545578a79ab4a896ba4aadb authorNick Fitzgerald <fitzgen@gmail.com> dateMon 25 Mar 2019, 14:22 (8 years ago) parent3b3b186
19 files changed+132−115
README.md+1−1 benches/benches.rs+9−7 crates/js-api/src/lib.rs+1−1 examples/counter/src/lib.rs+3−3 examples/game-of-life/src/lib.rs+3−6 examples/hello-world/src/lib.rs+1−1 examples/input-form/src/lib.rs+2−2 examples/js-component/src/lib.rs+1−1 examples/moire/src/lib.rs+4−4 examples/sierpinski-triangle/src/lib.rs+2−2 examples/todomvc/src/todo.rs+6−6 examples/todomvc/src/todos.rs+15−18 src/builder.rs+11−4 src/lib.rs+2−2 src/render.rs+2−2 src/render_context.rs+14 tests/web/events.rs+2−2 tests/web/js_api.rs+7−7 tests/web/render.rs+46−46
README.md+1−1
@@ -35,7 +35,7 @@ impl Render for Hello {
3535 where
3636 'a: 'bump,
3737 {
38− span(cx.bump)
38+ span(cx)
3939 .children([text("Hello, "), text(&self.who), text("!")])
4040 .finish()
4141 }
benches/benches.rs+9−7
@@ -10,14 +10,14 @@ use criterion::{
1010use dodrio::{
1111 builder::*,
1212 bumpalo::{self, Bump},
13− Node, Render, Vdom,
13+ Node, Render, RenderContext, Vdom,
1414};
1515
1616/// The simplest thing we can render: `<div/>`.
1717struct Empty;
1818impl Render for Empty {
1919 fn render<'bump>(&self, cx: &mut RenderContext<'bump>) -> Node<'bump> {
20− div(cx.bump).finish()
20+ div(&cx).finish()
2121 }
2222}
2323
@@ -25,9 +25,9 @@ impl Render for Empty {
2525struct SimpleList(usize);
2626impl Render for SimpleList {
2727 fn render<'bump>(&self, cx: &mut RenderContext<'bump>) -> Node<'bump> {
28− let mut children = bumpalo::collections::Vec::with_capacity_in(self.0, bump);
28+ let mut children = bumpalo::collections::Vec::with_capacity_in(self.0, cx.bump);
2929 children.extend((0..self.0).map(|_| {
30− li(bump)
30+ li(&cx)
3131 .attr("class", "my-list-item")
3232 .on("click", |_root, _vdom, _event| {
3333 panic!("no one should call this")
@@ -35,7 +35,7 @@ impl Render for SimpleList {
3535 .children([text("a list item")])
3636 .finish()
3737 }));
38− ol(bump).attr("id", "my-list").children(children).finish()
38+ ol(&cx).attr("id", "my-list").children(children).finish()
3939 }
4040}
4141
@@ -46,8 +46,9 @@ fn criterion_benchmark(c: &mut Criterion) {
4646 let mut bump = Bump::new();
4747 move |b| {
4848 bump.reset();
49+ let mut cx = RenderContext::new(&bump);
4950 b.iter(|| {
50− black_box(Empty.render(&bump));
51+ black_box(Empty.render(&mut cx));
5152 })
5253 }
5354 }),
@@ -61,8 +62,9 @@ fn criterion_benchmark(c: &mut Criterion) {
6162 let mut bump = Bump::new();
6263 move |b, n| {
6364 bump.reset();
65+ let mut cx = RenderContext::new(&bump);
6466 b.iter(|| {
65− black_box(SimpleList(*n).render(&bump));
67+ black_box(SimpleList(*n).render(&mut cx));
6668 })
6769 }
6870 },
crates/js-api/src/lib.rs+1−1
@@ -102,7 +102,7 @@ impl GreetingViaJs {
102102impl Render for GreetingViaJs {
103103 fn render<'bump>(&self, cx: &mut RenderContext<'bump>) -> Node<'bump> {
104104 use dodrio::builder::*;
105− p(cx.bump)
105+ p(&cx)
106106 .children([
107107 text("JavaScript says: "),
108108 self.js.render(cx),
examples/counter/src/lib.rs+3−3
@@ -33,9 +33,9 @@ impl Render for Counter {
3333 // Stringify the count as a bump-allocated string.
3434 let count = bumpalo::format!(in cx.bump, "{}", self.count);
3535
36− div(cx.bump)
36+ div(&cx)
3737 .children([
38− button(cx.bump)
38+ button(&cx)
3939 .on("click", |root, vdom, _event| {
4040 // Cast the root render component to a `Counter`, since
4141 // we know that's what it is.
@@ -51,7 +51,7 @@ impl Render for Counter {
5151 .children([text("+")])
5252 .finish(),
5353 text(count.into_bump_str()),
54− button(cx.bump)
54+ button(&cx)
5555 .on("click", |root, vdom, _event| {
5656 // Same as above, but decrementing instead of incrementing.
5757 root.unwrap_mut::<Counter>().decrement();
examples/game-of-life/src/lib.rs+3−6
@@ -139,7 +139,7 @@ impl Render for Universe {
139139
140140 for cell in row {
141141 cells.push(
142− span(cx.bump)
142+ span(&cx)
143143 .attr("class", "cell")
144144 .attr(
145145 "style",
@@ -152,13 +152,10 @@ impl Render for Universe {
152152 );
153153 }
154154
155− rows.push(div(cx.bump).attr("class", "row").children(cells).finish());
155+ rows.push(div(&cx).attr("class", "row").children(cells).finish());
156156 }
157157
158− div(cx.bump)
159− .attr("class", "universe")
160− .children(rows)
161− .finish()
158+ div(&cx).attr("class", "universe").children(rows).finish()
162159 }
163160}
164161
examples/hello-world/src/lib.rs+1−1
@@ -14,7 +14,7 @@ impl Render for Hello {
1414 fn render<'bump>(&self, cx: &mut RenderContext<'bump>) -> Node<'bump> {
1515 let msg = bumpalo::format!(in cx.bump, "Hello, {}!", self.who);
1616 let msg = msg.into_bump_str();
17− p(cx.bump).children([text(msg)]).finish()
17+ p(&cx).children([text(msg)]).finish()
1818 }
1919}
2020
examples/input-form/src/lib.rs+2−2
@@ -27,9 +27,9 @@ impl Render for SayHelloTo {
2727 fn render<'bump>(&self, cx: &mut RenderContext<'bump>) -> Node<'bump> {
2828 use dodrio::builder::*;
2929
30− div(cx.bump)
30+ div(&cx)
3131 .children([
32− input(cx.bump)
32+ input(&cx)
3333 .attr("type", "text")
3434 .attr(
3535 "value",
examples/js-component/src/lib.rs+1−1
@@ -34,7 +34,7 @@ impl GreetingViaJs {
3434impl Render for GreetingViaJs {
3535 fn render<'bump>(&self, cx: &mut RenderContext<'bump>) -> Node<'bump> {
3636 use dodrio::builder::*;
37− p(cx.bump)
37+ p(&cx)
3838 .children([text("JavaScript says: "), self.js.render(cx)])
3939 .finish()
4040 }
examples/moire/src/lib.rs+4−4
@@ -116,12 +116,12 @@ impl Render for Moire {
116116 .now();
117117 let elapsed = elapsed / 1600.0;
118118
119− main(cx.bump)
119+ main(&cx)
120120 .attr("style", self.moire_style(cx, elapsed))
121121 .children([
122122 // The `<input>` that lets users control how many circles to
123123 // render.
124− input(cx.bump)
124+ input(&cx)
125125 .attr("id", "circle-count")
126126 .attr("type", "range")
127127 .attr("min", "30")
@@ -192,7 +192,7 @@ impl Moire {
192192 y: f64,
193193 ) -> Node<'bump> {
194194 use dodrio::builder::*;
195− div(cx.bump)
195+ div(&cx)
196196 .attr("class", "object")
197197 .attr("style", self.moving_object_style(cx, x, y))
198198 .children([self.circle(cx, elapsed, self.count)])
@@ -215,7 +215,7 @@ impl Moire {
215215
216216 let r = n * 16;
217217
218− let mut circle = div(cx.bump)
218+ let mut circle = div(&cx)
219219 .attr("class", "circle")
220220 .attr("data-radius", {
221221 let r = bumpalo::format!(in cx.bump, "{}", r);
examples/sierpinski-triangle/src/lib.rs+2−2
@@ -61,7 +61,7 @@ impl Container {
6161 ) -> Node<'bump> {
6262 use dodrio::builder::{div, text};
6363
64− div(cx.bump)
64+ div(&cx)
6565 .attr("class", "dot")
6666 .attr("style", self.dot_style(cx, x, y))
6767 .child(text(
@@ -112,7 +112,7 @@ impl Render for Container {
112112 let mut children = bumpalo::collections::Vec::new_in(cx.bump);
113113 self.triangle(cx, 0.0, 0.0, 1000.0, modulus, &mut children);
114114
115− div(cx.bump)
115+ div(&cx)
116116 .attr("class", "container")
117117 .attr("style", self.container_transform(cx, elapsed))
118118 .children(children)
examples/todomvc/src/todo.rs+6−6
@@ -103,7 +103,7 @@ impl<C: TodoActions> Render for Todo<C> {
103103 let title = self.edits.as_ref().unwrap_or(&self.title);
104104 let title = bumpalo::format!(in cx.bump, "{}", title).into_bump_str();
105105
106− li(cx.bump)
106+ li(&cx)
107107 .attr("class", {
108108 let mut class = String::new_in(cx.bump);
109109 if self.completed {
@@ -115,10 +115,10 @@ impl<C: TodoActions> Render for Todo<C> {
115115 class.into_bump_str()
116116 })
117117 .children([
118− div(cx.bump)
118+ div(&cx)
119119 .attr("class", "view")
120120 .children([
121− input(cx.bump)
121+ input(&cx)
122122 .attr("class", "toggle")
123123 .attr("type", "checkbox")
124124 .bool_attr("checked", self.completed)
@@ -126,13 +126,13 @@ impl<C: TodoActions> Render for Todo<C> {
126126 C::toggle_completed(root, vdom, id);
127127 })
128128 .finish(),
129− label(cx.bump)
129+ label(&cx)
130130 .on("dblclick", move |root, vdom, _event| {
131131 C::begin_editing(root, vdom, id);
132132 })
133133 .children([text(title)])
134134 .finish(),
135− button(cx.bump)
135+ button(&cx)
136136 .attr("class", "destroy")
137137 .on("click", move |root, vdom, _event| {
138138 C::delete(root, vdom, id);
@@ -140,7 +140,7 @@ impl<C: TodoActions> Render for Todo<C> {
140140 .finish(),
141141 ])
142142 .finish(),
143− input(cx.bump)
143+ input(&cx)
144144 .attr("class", "edit")
145145 .attr("value", title)
146146 .attr("name", "title")
examples/todomvc/src/todos.rs+15−18
@@ -136,11 +136,11 @@ impl<C: TodosActions> Todos<C> {
136136 fn header<'bump>(&self, cx: &mut RenderContext<'bump>) -> Node<'bump> {
137137 use dodrio::builder::*;
138138
139− header(cx.bump)
139+ header(&cx)
140140 .attr("class", "header")
141141 .children([
142− h1(cx.bump).children([text("todos")]).finish(),
143− input(cx.bump)
142+ h1(&cx).children([text("todos")]).finish(),
143+ input(&cx)
144144 .on("input", |root, vdom, event| {
145145 let input = event
146146 .target()
@@ -181,7 +181,7 @@ impl<C: TodosActions> Todos<C> {
181181 .map(|t| t.render(cx)),
182182 );
183183
184− section(cx.bump)
184+ section(&cx)
185185 .attr("class", "main")
186186 .attr(
187187 "visibility",
@@ -192,7 +192,7 @@ impl<C: TodosActions> Todos<C> {
192192 },
193193 )
194194 .children([
195− input(cx.bump)
195+ input(&cx)
196196 .attr("class", "toggle-all")
197197 .attr("id", "toggle-all")
198198 .attr("type", "checkbox")
@@ -202,14 +202,11 @@ impl<C: TodosActions> Todos<C> {
202202 C::toggle_all(root, vdom);
203203 })
204204 .finish(),
205− label(cx.bump)
205+ label(&cx)
206206 .attr("for", "toggle-all")
207207 .children([text("Mark all as complete")])
208208 .finish(),
209− ul(cx.bump)
210− .attr("class", "todo-list")
211− .children(todos)
212− .finish(),
209+ ul(&cx).attr("class", "todo-list").children(todos).finish(),
213210 ])
214211 .finish()
215212 }
@@ -232,20 +229,20 @@ impl<C: TodosActions> Todos<C> {
232229 self.todos.iter().filter(|t| t.is_complete()).count()
233230 );
234231
235− footer(cx.bump)
232+ footer(&cx)
236233 .attr("class", "footer")
237234 .bool_attr("hidden", self.todos.is_empty())
238235 .children([
239− span(cx.bump)
236+ span(&cx)
240237 .attr("class", "todo-count")
241238 .children([
242− strong(cx.bump)
239+ strong(&cx)
243240 .children([text(incomplete_count.into_bump_str())])
244241 .finish(),
245242 text(items_left),
246243 ])
247244 .finish(),
248− ul(cx.bump)
245+ ul(&cx)
249246 .attr("class", "filters")
250247 .children([
251248 self.visibility_swap(cx, "#/", Visibility::All),
@@ -253,7 +250,7 @@ impl<C: TodosActions> Todos<C> {
253250 self.visibility_swap(cx, "#/completed", Visibility::Completed),
254251 ])
255252 .finish(),
256− button(cx.bump)
253+ button(&cx)
257254 .on("click", |root, vdom, _event| {
258255 C::delete_completed(root, vdom);
259256 })
@@ -273,11 +270,11 @@ impl<C: TodosActions> Todos<C> {
273270 ) -> Node<'bump> {
274271 use dodrio::builder::*;
275272
276− li(cx.bump)
273+ li(&cx)
277274 .on("click", move |root, vdom, _event| {
278275 C::change_visibility(root, vdom, target_vis);
279276 })
280− .children([a(cx.bump)
277+ .children([a(&cx)
281278 .attr("href", url)
282279 .attr(
283280 "class",
@@ -297,7 +294,7 @@ impl<C: TodosActions> Render for Todos<C> {
297294 fn render<'bump>(&self, cx: &mut RenderContext<'bump>) -> Node<'bump> {
298295 use dodrio::builder::*;
299296
300− div(cx.bump)
297+ div(&cx)
301298 .children([self.header(cx), self.todos_list(cx), self.footer(cx)])
302299 .finish()
303300 }
src/builder.rs+11−4
@@ -54,7 +54,11 @@ impl<'a>
5454 /// let my_element_builder = ElementBuilder::new(&b, tag_name);
5555 /// # fn flip_coin() -> bool { true }
5656 /// ```
57− pub fn new(bump: &'a Bump, tag_name: &'a str) -> Self {
57+ pub fn new<B>(bump: B, tag_name: &'a str) -> Self
58+ where
59+ B: Into<&'a Bump>,
60+ {
61+ let bump = bump.into();
5862 ElementBuilder {
5963 bump,
6064 tag_name,
@@ -378,14 +382,17 @@ macro_rules! builder_constructors {
378382 $(
379383 $(#[$attr])*
380384 #[inline]
381− pub fn $name<'a>(
382− bump: &'a Bump,
385+ pub fn $name<'a, B>(
386+ bump: B,
383387 ) -> ElementBuilder<
384388 'a,
385389 bumpalo::collections::Vec<'a, Listener<'a>>,
386390 bumpalo::collections::Vec<'a, Attribute<'a>>,
387391 bumpalo::collections::Vec<'a, Node<'a>>,
388− > {
392+ >
393+ where
394+ B: Into<&'a Bump>
395+ {
389396 ElementBuilder::new(bump, stringify!($name))
390397 }
391398 )*
src/lib.rs+2−2
@@ -25,7 +25,7 @@
2525//! let id = bumpalo::format!(in cx.bump, "hello-{}", self.who);
2626//! let who = bumpalo::collections::String::from_str_in(self.who, cx.bump).into_bump_str();
2727//!
28−//! div(cx.bump)
28+//! div(&cx)
2929//! .attr("id", id.into_bump_str())
3030//! .on("click", |root, _vdom, _event| {
3131//! let hello = root.unwrap_mut::<Hello>();
@@ -35,7 +35,7 @@
3535//! })
3636//! .children([
3737//! text("Hello, "),
38−//! strong(cx.bump)
38+//! strong(&cx)
3939//! .children([
4040//! text(who),
4141//! text("!"),
src/render.rs+2−2
@@ -25,10 +25,10 @@ use wasm_bindgen::UnwrapThrowExt;
2525/// fn render<'bump>(&self, cx: &mut RenderContext<'bump>) -> Node<'bump> {
2626/// use dodrio::builder::*;
2727///
28−/// p(cx.bump)
28+/// p(&cx)
2929/// .children([
3030/// text("This is "),
31−/// strong(cx.bump).children([text("my component")]).finish(),
31+/// strong(&cx).children([text("my component")]).finish(),
3232/// text(" rendered!"),
3333/// ])
3434/// .finish()
src/render_context.rs+14
@@ -36,3 +36,17 @@ impl<'bump> RenderContext<'bump> {
3636 }
3737 }
3838}
39+
40+impl<'a, 'bump> From<&'a RenderContext<'bump>> for &'bump Bump {
41+ #[inline]
42+ fn from(cx: &'a RenderContext<'bump>) -> &'bump Bump {
43+ cx.bump
44+ }
45+}
46+
47+impl<'a, 'b, 'bump> From<&'a &'b mut RenderContext<'bump>> for &'bump Bump {
48+ #[inline]
49+ fn from(cx: &'a &'b mut RenderContext<'bump>) -> &'bump Bump {
50+ cx.bump
51+ }
52+}
tests/web/events.rs+2−2
@@ -27,7 +27,7 @@ impl EventContainer {
2727impl Render for EventContainer {
2828 fn render<'bump>(&self, cx: &mut RenderContext<'bump>) -> Node<'bump> {
2929 use dodrio::builder::*;
30− div(cx.bump)
30+ div(&cx)
3131 .attr("id", "target")
3232 .on(self.event, |root, _scheduler, _event| {
3333 (root.unwrap_mut::<EventContainer>().on_event)();
@@ -140,7 +140,7 @@ impl Render for ListensOnlyOnFirstRender {
140140 let count = self.count.get();
141141 self.count.set(count + 1);
142142
143− let mut elem = div(cx.bump).attr("id", "target");
143+ let mut elem = div(&cx).attr("id", "target");
144144 if count == 0 {
145145 elem = elem.on("click", |root, _scheduler, _event| {
146146 (root.unwrap_mut::<ListensOnlyOnFirstRender>().callback)();
tests/web/js_api.rs+7−7
@@ -38,7 +38,7 @@ impl WrapJs {
3838
3939impl Render for WrapJs {
4040 fn render<'bump>(&self, cx: &mut RenderContext<'bump>) -> Node<'bump> {
41− div(cx.bump)
41+ div(&cx)
4242 .attr("class", "wrap-js")
4343 .children([self.inner.render(cx)])
4444 .finish()
@@ -107,13 +107,13 @@ fn can_use_js_rendering_components() -> impl Future<Item = (), Error = JsValue>
107107 assert_rendered(
108108 &container,
109109 &RenderFn(|cx| {
110− div(cx.bump)
110+ div(&cx)
111111 .attr("class", "wrap-js")
112− .children([span(cx.bump)
112+ .children([span(&cx)
113113 .attr("class", "js-component")
114114 .children([
115115 text("Here is some plain text"),
116− b(cx.bump)
116+ b(&cx)
117117 .children([text("...and here is some bold text")])
118118 .finish(),
119119 text("0"),
@@ -136,13 +136,13 @@ fn can_use_js_rendering_components() -> impl Future<Item = (), Error = JsValue>
136136 assert_rendered(
137137 &container,
138138 &RenderFn(|cx| {
139− div(cx.bump)
139+ div(&cx)
140140 .attr("class", "wrap-js")
141− .children([span(cx.bump)
141+ .children([span(&cx)
142142 .attr("class", "js-component")
143143 .children([
144144 text("Here is some plain text"),
145− b(cx.bump)
145+ b(&cx)
146146 .children([text("...and here is some bold text")])
147147 .finish(),
148148 text("1"),
tests/web/render.rs+46−46
@@ -16,9 +16,9 @@ fn render_initial_text() {
1616#[wasm_bindgen_test]
1717fn render_initial_node() {
1818 let hello = Rc::new(RenderFn(|cx| {
19− div(cx.bump)
19+ div(&cx)
2020 .attr("id", "hello-world")
21− .children([text("Hello "), span(cx.bump).child(text("World!")).finish()])
21+ .children([text("Hello "), span(&cx).child(text("World!")).finish()])
2222 .finish()
2323 }));
2424
@@ -59,13 +59,13 @@ before_after! {
5959 text("before")
6060 }
6161 after(cx) {
62− div(cx.bump).finish()
62+ div(&cx).finish()
6363 }
6464 }
6565
6666 replace_elem_with_text {
6767 before(cx) {
68− div(cx.bump).finish()
68+ div(&cx).finish()
6969 }
7070 after(_cx) {
7171 text("before")
@@ -74,52 +74,52 @@ before_after! {
7474
7575 same_elem {
7676 before(cx) {
77− div(cx.bump).finish()
77+ div(&cx).finish()
7878 }
7979 after(cx) {
80− div(cx.bump).finish()
80+ div(&cx).finish()
8181 }
8282 }
8383
8484 elems_with_different_tag_names {
8585 before(cx) {
86− span(cx.bump).finish()
86+ span(&cx).finish()
8787 }
8888 after(cx) {
89− div(cx.bump).finish()
89+ div(&cx).finish()
9090 }
9191 }
9292
9393 same_tag_name_update_attribute {
9494 before(cx) {
95− div(cx.bump).attr("value", "1").finish()
95+ div(&cx).attr("value", "1").finish()
9696 }
9797 after(cx) {
98− div(cx.bump).attr("value", "2").finish()
98+ div(&cx).attr("value", "2").finish()
9999 }
100100 }
101101
102102 same_tag_name_remove_attribute {
103103 before(cx) {
104− div(cx.bump).attr("value", "1").finish()
104+ div(&cx).attr("value", "1").finish()
105105 }
106106 after(cx) {
107− div(cx.bump).finish()
107+ div(&cx).finish()
108108 }
109109 }
110110
111111 same_tag_name_add_attribute {
112112 before(cx) {
113− div(cx.bump).finish()
113+ div(&cx).finish()
114114 }
115115 after(cx) {
116− div(cx.bump).attr("value", "2").finish()
116+ div(&cx).attr("value", "2").finish()
117117 }
118118 }
119119
120120 same_tag_name_many_attributes {
121121 before(cx) {
122− div(cx.bump)
122+ div(&cx)
123123 .attr("before-1", "1")
124124 .attr("shared-1", "1")
125125 .attr("modified-1", "1")
@@ -132,7 +132,7 @@ before_after! {
132132 .finish()
133133 }
134134 after(cx) {
135− div(cx.bump)
135+ div(&cx)
136136 .attr("after-1", "1")
137137 .attr("shared-1", "1")
138138 .attr("modified-1", "100")
@@ -148,56 +148,56 @@ before_after! {
148148
149149 same_tag_same_children {
150150 before(cx) {
151− div(cx.bump).child(text("child")).finish()
151+ div(&cx).child(text("child")).finish()
152152 }
153153 after(cx) {
154− div(cx.bump).child(text("child")).finish()
154+ div(&cx).child(text("child")).finish()
155155 }
156156 }
157157
158158 same_tag_update_child {
159159 before(cx) {
160− div(cx.bump).child(text("before")).finish()
160+ div(&cx).child(text("before")).finish()
161161 }
162162 after(cx) {
163− div(cx.bump).child(text("after")).finish()
163+ div(&cx).child(text("after")).finish()
164164 }
165165 }
166166
167167 same_tag_add_child {
168168 before(cx) {
169− div(cx.bump).finish()
169+ div(&cx).finish()
170170 }
171171 after(cx) {
172− div(cx.bump).child(text("child")).finish()
172+ div(&cx).child(text("child")).finish()
173173 }
174174 }
175175
176176 same_tag_remove_child {
177177 before(cx) {
178− div(cx.bump).child(text("child")).finish()
178+ div(&cx).child(text("child")).finish()
179179 }
180180 after(cx) {
181− div(cx.bump).finish()
181+ div(&cx).finish()
182182 }
183183 }
184184
185185 same_tag_update_many_children {
186186 before(cx) {
187− div(cx.bump)
187+ div(&cx)
188188 .children([
189− div(cx.bump).finish(),
190− span(cx.bump).finish(),
191− p(cx.bump).finish(),
189+ div(&cx).finish(),
190+ span(&cx).finish(),
191+ p(&cx).finish(),
192192 ])
193193 .finish()
194194 }
195195 after(cx) {
196− div(cx.bump)
196+ div(&cx)
197197 .children([
198− span(cx.bump).finish(),
199− p(cx.bump).finish(),
200− div(cx.bump).finish(),
198+ span(&cx).finish(),
199+ p(&cx).finish(),
200+ div(&cx).finish(),
201201 ])
202202 .finish()
203203 }
@@ -205,18 +205,18 @@ before_after! {
205205
206206 same_tag_remove_many_children {
207207 before(cx) {
208− div(cx.bump)
208+ div(&cx)
209209 .children([
210− div(cx.bump).finish(),
211− span(cx.bump).finish(),
212− p(cx.bump).finish(),
210+ div(&cx).finish(),
211+ span(&cx).finish(),
212+ p(&cx).finish(),
213213 ])
214214 .finish()
215215 }
216216 after(cx) {
217− div(cx.bump)
217+ div(&cx)
218218 .children([
219− div(cx.bump).finish(),
219+ div(&cx).finish(),
220220 ])
221221 .finish()
222222 }
@@ -224,18 +224,18 @@ before_after! {
224224
225225 same_tag_add_many_children {
226226 before(cx) {
227− div(cx.bump)
227+ div(&cx)
228228 .children([
229− div(cx.bump).finish(),
229+ div(&cx).finish(),
230230 ])
231231 .finish()
232232 }
233233 after(cx) {
234− div(cx.bump)
234+ div(&cx)
235235 .children([
236− div(cx.bump).finish(),
237− span(cx.bump).finish(),
238− p(cx.bump).finish(),
236+ div(&cx).finish(),
237+ span(&cx).finish(),
238+ p(&cx).finish(),
239239 ])
240240 .finish()
241241 }
@@ -243,12 +243,12 @@ before_after! {
243243
244244 same_tag_different_namespace {
245245 before(cx) {
246− div(cx.bump)
246+ div(&cx)
247247 .namespace(Some("http://example.com"))
248248 .finish()
249249 }
250250 after(cx) {
251− div(cx.bump)
251+ div(&cx)
252252 .namespace(Some("http://example.net"))
253253 .finish()
254254 }