on develop help sign in
Fix treatment of textnode initial value in static renderer
commit2e2531506a20f4984bced74e673faa5b045add2c authorTom Smalley <tfsmalley@gmail.com> dateWed 8 Jul 2020, 15:38 (6 years ago) parent181cf77
1 file changed+6−8
reflex-dom-core/src/Reflex/Dom/Builder/Static.hs+6−8
reflex-dom-core/src/Reflex/Dom/Builder/Static.hs+6−8
@@ -37,6 +37,7 @@ import Data.IntMap (IntMap)
3737import qualified Data.IntMap as IntMap
3838import qualified Data.Map as Map
3939import Data.Map.Misc (applyMap)
40+import Data.Maybe (fromMaybe)
4041import Data.Monoid ((<>))
4142import qualified Data.Set as Set
4243import Data.Text (Text)
@@ -334,14 +335,11 @@ instance SupportsStaticDomBuilder t m => DomBuilder t (StaticDomBuilderT t m) wh
334335 }
335336 {-# INLINABLE textAreaElement #-}
336337 textAreaElement cfg = do
337− -- Tweak the config to update the "value" attribute appropriately.
338− -- TODO: warn upon overwriting values.
339− let adjustedConfig = (_textAreaElementConfig_elementConfig cfg)
340− & elementConfig_initialAttributes %~ Map.insert "value" (_textAreaElementConfig_initialValue cfg)
341− & elementConfig_modifyAttributes %~ (case _textAreaElementConfig_setValue cfg of
342− Nothing -> id
343− Just e -> \e' -> (Map.singleton "value" . Just <$> e) <> e')
344− (e, _domElement) <- element "textarea" adjustedConfig $ return ()
338+ (e, _domElement) <- element "textarea" (_textAreaElementConfig_elementConfig cfg) $ do
339+ -- Set the initial value
340+ void $ textNode $ def
341+ & textNodeConfig_initialContents .~ _textAreaElementConfig_initialValue cfg
342+ & textNodeConfig_setContents .~ fromMaybe never (_textAreaElementConfig_setValue cfg)
345343 let v0 = constDyn $ cfg ^. textAreaElementConfig_initialValue
346344 let hasFocus = constDyn False -- TODO should this be coming from initialAtttributes
347345 return $ TextAreaElement