on develop help sign in
Make deleteBetweenInclusive more lenient (like deleteBetweenExclusive)
f8f8af4Ryan Trinkle
src/Reflex/Dom/Widget/Basic.hs+11−7
@@ -350,13 +350,17 @@ deleteBetweenExclusive s e = do
350
350
351-- | s and e must both be children of the same node and s must precede e
351-- | s and e must both be children of the same node and s must precede e
352deleteBetweenInclusive s e = do
352deleteBetweenInclusive s e = do
353− Just currentParent <- nodeGetParentNode e -- May be different than it was at initial construction, e.g., because the parent may have dumped us in from a DocumentFragment
353+ mCurrentParent <- nodeGetParentNode e -- May be different than it was at initial construction, e.g., because the parent may have dumped us in from a DocumentFragment
354+ case mCurrentParent of
355+ Nothing -> return () --TODO: Is this the right behavior?
356+ Just currentParent -> do
354− let go = do
357+ let go = do
355− Just x <- nodeGetPreviousSibling e -- This can't be Nothing because we should hit 's' first
358+ Just x <- nodeGetPreviousSibling e -- This can't be Nothing because we should hit 's' first
356− nodeRemoveChild currentParent $ Just x
359+ nodeRemoveChild currentParent $ Just x
357− when (unNode (toNode s) /= unNode (toNode x)) go
360+ when (unNode (toNode s) /= unNode (toNode x)) go
358− go
361+ go
359− nodeRemoveChild currentParent $ Just e
362+ nodeRemoveChild currentParent $ Just e
363+ return ()
360
364
361--------------------------------------------------------------------------------
365--------------------------------------------------------------------------------
362-- Adapters
366-- Adapters