on develop help sign in
Switch selectValue to behavior.
commitd85b3004413e4e13128c18d0a8e30779ab06eed3 authorLuigy Leon <luigy@outlook.com> dateTue 17 Jan 2017, 23:33 (10 years ago) parent700f480
1 file changed+5−5
src/Reflex/Dom/Builder/Static.hs+5−5
src/Reflex/Dom/Builder/Static.hs+5−5
@@ -53,7 +53,7 @@ import Reflex.TriggerEvent.Class
5353
5454data StaticDomBuilderEnv t = StaticDomBuilderEnv
5555 { _staticDomBuilderEnv_shouldEscape :: Bool
56− , _staticDomBuilderEnv_selectValue :: Maybe (Dynamic t Text)
56+ , _staticDomBuilderEnv_selectValue :: Maybe (Behavior t Text)
5757 }
5858
5959newtype StaticDomBuilderT t m a = StaticDomBuilderT
@@ -192,9 +192,9 @@ instance SupportsStaticDomBuilder t m => DomBuilder t (StaticDomBuilderT t m) wh
192192 Just v | v == sel -> attrs <> Map.singleton "selected" ""
193193 _ -> Map.delete "selected" attrs
194194 let attrs1 = case selectValue of
195− Nothing -> attrs0
196− Just sv -> zipDynWith addSelectedAttr attrs0 sv
197− let attrs2 = ffor (current attrs1) $ mconcat . fmap (\(k, v) -> " " <> toAttr k v) . Map.toList
195+ Nothing -> current attrs0
196+ Just sv -> pull $ addSelectedAttr <$> sample (current attrs0) <*> sample sv
197+ let attrs2 = ffor attrs1 $ mconcat . fmap (\(k, v) -> " " <> toAttr k v) . Map.toList
198198 let tagBS = encodeUtf8 elementTag
199199 if Set.member elementTag voidElements
200200 then modify $ (:) $ mconcat [constant ("<" <> byteString tagBS), attrs2, constant (byteString " />")]
@@ -235,7 +235,7 @@ instance SupportsStaticDomBuilder t m => DomBuilder t (StaticDomBuilderT t m) wh
235235 selectElement cfg child = do
236236 v <- holdDyn (cfg ^. selectElementConfig_initialValue) (cfg ^. selectElementConfig_setValue)
237237 (e, result) <- element "select" (_selectElementConfig_elementConfig cfg) $ do
238− (a, innerHtml) <- StaticDomBuilderT $ lift $ lift $ runStaticDomBuilderT child $ StaticDomBuilderEnv False (Just v)
238+ (a, innerHtml) <- StaticDomBuilderT $ lift $ lift $ runStaticDomBuilderT child $ StaticDomBuilderEnv False $ Just (current v)
239239 StaticDomBuilderT $ lift $ modify $ (:) innerHtml
240240 return a
241241 let wrapped = SelectElement