on develop help sign in
Add HasValue, InitialAttributes, and ModifyAttributes instances for InputElement and TextAreaElement
commitd8cb71eb82e18a0ab316cbf108712d042f88bc3b authorRyan Trinkle <ryan.trinkle@gmail.com> dateMon 15 Aug 2016, 18:42 (10 years ago) parente0082a2
2 files changed+24
src/Reflex/Dom/Builder/Class.hs+16 src/Reflex/Dom/Widget/Input.hs+8
src/Reflex/Dom/Builder/Class.hs+16
@@ -247,6 +247,14 @@ instance InitialAttributes (ElementConfig er t m) where
247247 {-# INLINABLE initialAttributes #-}
248248 initialAttributes = elementConfig_initialAttributes
249249
250+instance InitialAttributes (InputElementConfig er t m) where
251+ {-# INLINABLE initialAttributes #-}
252+ initialAttributes = inputElementConfig_elementConfig . elementConfig_initialAttributes
253+
254+instance InitialAttributes (TextAreaElementConfig er t m) where
255+ {-# INLINABLE initialAttributes #-}
256+ initialAttributes = textAreaElementConfig_elementConfig . elementConfig_initialAttributes
257+
250258class ModifyAttributes t a | a -> t where
251259 modifyAttributes :: Lens' a (Event t (Map AttributeName (Maybe Text)))
252260
@@ -254,6 +262,14 @@ instance ModifyAttributes t (ElementConfig er t m) where
254262 {-# INLINABLE modifyAttributes #-}
255263 modifyAttributes = elementConfig_modifyAttributes
256264
265+instance ModifyAttributes t (InputElementConfig er t m) where
266+ {-# INLINABLE modifyAttributes #-}
267+ modifyAttributes = inputElementConfig_elementConfig . elementConfig_modifyAttributes
268+
269+instance ModifyAttributes t (TextAreaElementConfig er t m) where
270+ {-# INLINABLE modifyAttributes #-}
271+ modifyAttributes = textAreaElementConfig_elementConfig . elementConfig_modifyAttributes
272+
257273instance ModifyAttributes t (RawElementConfig er t m) where
258274 {-# INLINABLE modifyAttributes #-}
259275 modifyAttributes = rawElementConfig_modifyAttributes
src/Reflex/Dom/Widget/Input.hs+8
@@ -515,6 +515,14 @@ class HasValue a where
515515 type Value a :: *
516516 value :: a -> Value a
517517
518+instance HasValue (InputElement er d t) where
519+ type Value (InputElement er d t) = Dynamic t Text
520+ value = _inputElement_value
521+
522+instance HasValue (TextAreaElement er d t) where
523+ type Value (TextAreaElement er d t) = Dynamic t Text
524+ value = _textAreaElement_value
525+
518526instance HasValue (TextArea t) where
519527 type Value (TextArea t) = Dynamic t Text
520528 value = _textArea_value