Skip to content

Commit 043d085

Browse files
committed
Allow hydrating into as well as onto.
1 parent da4f63e commit 043d085

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/coconut/diffing/Root.hx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,25 @@ package coconut.diffing;
22

33
import coconut.ui.internal.ImplicitContext;
44

5+
enum abstract Hydration(Int) {
6+
var No;
7+
var Into;
8+
var Onto;
9+
}
10+
511
class Root<Native> extends Parent {
612
final rendered:RCell<Native>;
713

8-
public function new(parent, applicator:Applicator<Native>, ?content, hydrate:Bool) {
14+
public function new(parent, applicator:Applicator<Native>, ?content, hydration = No) {
915
super(new ImplicitContext());
10-
var rendered = Parent.withLater(later -> new RCell(this, content, applicator.children(parent), later, hydrate));
16+
var rendered = Parent.withLater(later -> new RCell(this, content, if (hydration == Onto) applicator.siblings(parent) else applicator.children(parent), later, hydration != No));
1117
this.rendered = rendered;
1218
}
1319

1420
static final byParent = new Map<{}, Root<Dynamic>>();
1521
static public function fromNative<Native:{}>(parent:Native, applicator:Applicator<Native>):Root<Native>
1622
return cast switch byParent[parent] {
17-
case null: byParent[parent] = new Root(parent, applicator, false);
23+
case null: byParent[parent] = new Root(parent, applicator);
1824
case v: v;
1925
}
2026

tests/TodoMvc.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ class TodoMvc {
119119
@:privateAccess Renderer.BACKEND // meh
120120
#else DummyApplicator.INST #end,
121121
markup,
122-
hydrate
122+
if (hydrate) Into else No
123123
);
124124
if (hydrate) {
125125
asserts.assert(root.innerHTML == innerHTML);

0 commit comments

Comments
 (0)