Skip to content

Commit 87f145a

Browse files
authored
Sequence unsafe effects with magic-do (#14)
1 parent 9d78884 commit 87f145a

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/Halogen/VDom/DOM.purs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ buildText (VDomSpec spec) = render
8888
buildVDom (VDomSpec spec) vdom
8989

9090
done node = do
91-
Fn.runFn2 Util.removeChild node (Util.unsafeParent node)
91+
parent ← pure (Util.unsafeParent node)
92+
Fn.runFn2 Util.removeChild node parent
9293

9394
buildElem
9495
eff a w
@@ -130,7 +131,7 @@ buildElem (VDomSpec spec) = render
130131
res@Step n' m' h' ← step vdom
131132
Fn.runFn3 Util.insertChildIx ix n' node
132133
pure res
133-
onThis = Fn.mkFn2 \ix (res@Step n _ halt) → halt
134+
onThis = Fn.mkFn2 \ix (Step n _ halt) → halt
134135
onThat = Fn.mkFn2 \ix vdom → do
135136
res@Step n m h ← buildVDom (VDomSpec spec) vdom
136137
Fn.runFn3 Util.insertChildIx ix n node
@@ -146,7 +147,8 @@ buildElem (VDomSpec spec) = render
146147
buildVDom (VDomSpec spec) vdom
147148

148149
done = Fn.mkFn3 \node attrs steps → do
149-
Fn.runFn2 Util.removeChild node (Util.unsafeParent node)
150+
parent ← pure (Util.unsafeParent node)
151+
Fn.runFn2 Util.removeChild node parent
150152
foreachE steps Machine.halt
151153
Machine.halt attrs
152154

@@ -206,7 +208,8 @@ buildKeyed (VDomSpec spec) = render
206208
buildVDom (VDomSpec spec) vdom
207209

208210
done = Fn.mkFn3 \node attrs steps → do
209-
Fn.runFn2 Util.removeChild node (Util.unsafeParent node)
211+
parent ← pure (Util.unsafeParent node)
212+
Fn.runFn2 Util.removeChild node parent
210213
Fn.runFn2 Util.forInE steps (Fn.mkFn2 \_ (Step _ _ halt) → halt)
211214
Machine.halt attrs
212215

0 commit comments

Comments
 (0)