@@ -92,42 +92,43 @@ addVoidAction = performEvent_
9292
9393type AttributeMap = Map Text Text
9494
95−buildElement :: Attributes m attrs => Text -> attrs -> m a -> m (RawElement GhcjsDomSpace, a)
95+buildElement :: (MonadWidget t m, Attributes m attrs t) => Text -> attrs -> m a -> m (RawElement (DomBuilderSpace m), a)
9696buildElement = buildElementNS Nothing
9797
98−buildEmptyElement :: Monad m => Attributes m attrs => Text -> attrs -> m (RawElement GhcjsDomSpace)
98+buildEmptyElement :: (MonadWidget t m, Attributes m attrs t) => Text -> attrs -> m (RawElement (DomBuilderSpace m))
9999buildEmptyElement elementTag attrs = fst <$> buildElementNS Nothing elementTag attrs blank
100100
101−buildEmptyElementNS :: Monad m => Attributes m attrs => Maybe Text -> Text -> attrs -> m (RawElement GhcjsDomSpace)
101+buildEmptyElementNS :: (MonadWidget t m, Attributes m attrs t) => Maybe Text -> Text -> attrs -> m (RawElement (DomBuilderSpace m))
102102buildEmptyElementNS ns elementTag attrs = fst <$> buildElementNS ns elementTag attrs blank
103103
104−class Attributes m attrs where
105− buildElementNS :: Maybe Text -> Text -> attrs -> m a -> m (RawElement GhcjsDomSpace, a)
104+buildElementNS :: (MonadWidget t m, Attributes m attrs t) => Maybe Text -> Text -> attrs -> m a -> m (RawElement (DomBuilderSpace m), a)
105+buildElementNS ns elementTag attrs child = fmap (first _element_raw) $ buildElementInternal ns elementTag attrs child
106106
107−instance MonadWidget t m => Attributes m (Map Text Text) where
108− buildElementNS ns elementTag attrs child = do
107+class Attributes m attrs t where
108+ buildElementInternal :: MonadWidget t m => Maybe Text -> Text -> attrs -> m a -> m (Element EventResult (DomBuilderSpace m) t, a)
109+
110+instance Attributes m (Map Text Text) t where
111+ buildElementInternal ns elementTag attrs child = do
109112 let cfg = def & elementConfig_namespace .~ ns
110− buildElementInternal elementTag child =<< addStaticAttributes attrs cfg
113+ buildElementCommon elementTag child =<< addStaticAttributes attrs cfg
111114
112115addStaticAttributes :: Applicative m => Map Text Text -> ElementConfig er t m -> m (ElementConfig er t m)
113116addStaticAttributes attrs cfg = do
114117 let initialAttrs = Map.fromList $ fmap (first ((,) Nothing)) $ Map.toList attrs
115118 pure $ cfg & elementConfig_initialAttributes .~ initialAttrs
116119
117−instance MonadWidget t m => Attributes m (Dynamic t (Map Text Text)) where
118− buildElementNS ns elementTag attrs child = do
120+instance PostBuild t m => Attributes m (Dynamic t (Map Text Text)) t where
121+ buildElementInternal ns elementTag attrs child = do
119122 let cfg = def & elementConfig_namespace .~ ns
120− buildElementInternal elementTag child =<< addDynamicAttributes attrs cfg
123+ buildElementCommon elementTag child =<< addDynamicAttributes attrs cfg
121124
122125addDynamicAttributes :: PostBuild t m => Dynamic t (Map Text Text) -> ElementConfig er t m -> m (ElementConfig er t m)
123126addDynamicAttributes attrs cfg = do
124127 modifyAttrs <- dynamicAttributesToModifyAttributes attrs
125128 return $ cfg & elementConfig_modifyAttributes .~ modifyAttrs
126129
127−buildElementInternal :: MonadWidget t m => Text -> m a -> ElementConfig en t m -> m (DOM.HTMLElement, a)
128−buildElementInternal elementTag child cfg = do
129− (e, result) <- element elementTag cfg child
130− return (_element_raw e, result)
130+buildElementCommon :: MonadWidget t m => Text -> m a -> ElementConfig er t m -> m (Element er (DomBuilderSpace m) t, a)
131+buildElementCommon elementTag child cfg = element elementTag cfg child
131132
132133-- | s and e must both be children of the same node and s must precede e
133134deleteBetweenExclusive :: (IsNode start, IsNode end) => start -> end -> IO ()
@@ -161,14 +162,14 @@ instance HasAttributes (ElConfig attrs) where
161162instance HasNamespace (ElConfig attrs) where
162163 namespace = elConfig_namespace
163164
164−elWith :: (Functor m, Attributes m attrs) => Text -> ElConfig attrs -> m a -> m a
165+elWith :: (MonadWidget t m, Attributes m attrs t) => Text -> ElConfig attrs -> m a -> m a
165166elWith elementTag cfg child = snd <$> elWith' elementTag cfg child
166167
167−elWith' :: Attributes m attrs => Text -> ElConfig attrs -> m a -> m (DOM.HTMLElement, a)
168−elWith' elementTag cfg child = buildElementNS (cfg ^. namespace) elementTag (cfg ^. attributes) child
168+elWith' :: (MonadWidget t m, Attributes m attrs t) => Text -> ElConfig attrs -> m a -> m (Element EventResult (DomBuilderSpace m) t, a)
169+elWith' elementTag cfg child = buildElementInternal (cfg ^. namespace) elementTag (cfg ^. attributes) child
169170
170−emptyElWith :: (Monad m, Attributes m attrs) => Text -> ElConfig attrs -> m ()
171+emptyElWith :: (MonadWidget t m, Attributes m attrs t) => Text -> ElConfig attrs -> m ()
171172emptyElWith elementTag cfg = void $ emptyElWith' elementTag cfg
172173
173−emptyElWith' :: (Monad m, Attributes m attrs) => Text -> ElConfig attrs -> m DOM.HTMLElement
174−emptyElWith' elementTag cfg = liftM fst $ buildElementNS (cfg ^. namespace) elementTag (cfg ^. attributes) $ return ()
174+emptyElWith' :: (MonadWidget t m, Attributes m attrs t) => Text -> ElConfig attrs -> m (Element EventResult (DomBuilderSpace m) t)
175+emptyElWith' elementTag cfg = liftM fst $ elWith' elementTag cfg $ return ()