on develop help sign in
Fix runWithReplace initial widget not being added to DOM in immediate mode
commit4f142ef2e5494c5d996a099be8c9ed0d8aac3a81 authorTom Smalley <tfsmalley@gmail.com> dateTue 20 Nov 2018, 17:09 (8 years ago) parent785099b
1 file changed+12−4
reflex-dom-core/src/Reflex/Dom/Builder/Hydration.hs+12−4
reflex-dom-core/src/Reflex/Dom/Builder/Hydration.hs+12−4
@@ -973,11 +973,19 @@ instance (Reflex t, Adjustable t m, MonadJSM m, MonadHold t m, MonadFix m, PrimM
973973 parent <- getParent
974974 (hydrateEnd, after) <- skipToReplaceEnd beforeKey
975975 let drawInitialChild = do
976− p <- liftIO (readIORef hydrating) >>= \case
977− HydrationMode_Hydrating -> liftIO $ newIORef parent
978− HydrationMode_Immediate -> liftIO . newIORef . toNode =<< createDocumentFragment doc
976+ h <- liftIO $ readIORef hydrating
977+ p' <- case h of
978+ HydrationMode_Hydrating -> pure parent
979+ HydrationMode_Immediate -> toNode <$> createDocumentFragment doc
980+ p <- liftIO $ newIORef p'
979981 unreadyChildren <- liftIO $ newIORef 0
980− (result, dom) <- flip runStateT [] $ runReaderT (unHydrationDomBuilderT a0) initialEnv
982+ let a0' = case h of
983+ HydrationMode_Hydrating -> a0
984+ HydrationMode_Immediate -> do
985+ a <- a0
986+ insertBefore p' =<< liftIO (readIORef after)
987+ pure a
988+ (result, dom) <- flip runStateT [] $ runReaderT (unHydrationDomBuilderT a0') initialEnv
981989 { _hydrationDomBuilderEnv_unreadyChildren = unreadyChildren
982990 , _hydrationDomBuilderEnv_commitAction = myCommitAction
983991 , _hydrationDomBuilderEnv_parent = p