@@ -350,13 +350,17 @@ deleteBetweenExclusive s e = do
350350
351351-- | s and e must both be children of the same node and s must precede e
352352deleteBetweenInclusive 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
354− let go = do
355− Just x <- nodeGetPreviousSibling e -- This can't be Nothing because we should hit 's' first
356− nodeRemoveChild currentParent $ Just x
357− when (unNode (toNode s) /= unNode (toNode x)) go
358− go
359− nodeRemoveChild currentParent $ Just e
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
357+ let go = do
358+ Just x <- nodeGetPreviousSibling e -- This can't be Nothing because we should hit 's' first
359+ nodeRemoveChild currentParent $ Just x
360+ when (unNode (toNode s) /= unNode (toNode x)) go
361+ go
362+ nodeRemoveChild currentParent $ Just e
363+ return ()
360364
361365--------------------------------------------------------------------------------
362366-- Adapters