on develop help sign in
Ensure addSelectedAttr is used only for option elements.
4bf4ee8Luigy Leon
src/Reflex/Dom/Builder/Static.hs+3−3
@@ -191,9 +191,9 @@ instance SupportsStaticDomBuilder t m => DomBuilder t (StaticDomBuilderT t m) wh
191 let addSelectedAttr attrs sel = case Map.lookup "value" attrs of
191 let addSelectedAttr attrs sel = case Map.lookup "value" attrs of
192 Just v | v == sel -> attrs <> Map.singleton "selected" ""
192 Just v | v == sel -> attrs <> Map.singleton "selected" ""
193 _ -> Map.delete "selected" attrs
193 _ -> Map.delete "selected" attrs
194− let attrs1 = case selectValue of
194+ let attrs1 = case (elementTag, selectValue) of
195− Nothing -> current attrs0
196− Just sv -> pull $ addSelectedAttr <$> sample (current attrs0) <*> sample sv
195+ ("option", Just sv) -> pull $ addSelectedAttr <$> sample (current attrs0) <*> sample sv
196+ _ -> current attrs0
197 let attrs2 = ffor attrs1 $ mconcat . fmap (\(k, v) -> " " <> toAttr k v) . Map.toList
197 let attrs2 = ffor attrs1 $ mconcat . fmap (\(k, v) -> " " <> toAttr k v) . Map.toList
198 let tagBS = encodeUtf8 elementTag
198 let tagBS = encodeUtf8 elementTag
199 if Set.member elementTag voidElements
199 if Set.member elementTag voidElements