{-# LANGUAGE CPP #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE LambdaCase #-}
#ifdef USE_TEMPLATE_HASKELL
{-# LANGUAGE TemplateHaskell #-}
#endif
module Reflex.Dom.Old
       ( MonadWidget
       , El
       , ElConfig (..)
       , elConfig_namespace
       , elConfig_attributes
       , _el_clicked
       , _el_element
       , _el_events
       , addVoidAction
       , AttributeMap
       , Attributes (..)
       , buildElement
       , buildElementNS
       , buildEmptyElement
       , buildEmptyElementNS
       , elDynHtml'
       , elDynHtmlAttr'
       , elStopPropagationNS
       , elWith
       , elWith'
       , emptyElWith
       , emptyElWith'
       , namedNodeMapGetNames
       , nodeClear
       , onEventName
       , schedulePostBuild
       , text'
       , unsafePlaceElement
       , WidgetHost
       , wrapElement
       ) where

import Control.Arrow (first)
#ifdef USE_TEMPLATE_HASKELL
import Control.Lens (makeLenses, (%~), (&), (.~), (^.))
#else
import Control.Lens (Lens, Lens', (%~), (&), (.~), (^.))
#endif
import Control.Monad
import Control.Monad.Fix
import Control.Monad.IO.Class
import Control.Monad.Reader
import Control.Monad.Ref
import Data.Default
import Data.Dependent.Map as DMap
import Data.Functor.Misc
import Data.Map (Map)
import qualified Data.Map as Map
import Data.Set (Set)
import qualified Data.Set as Set
import Data.Text (Text)
import Foreign.JavaScript.TH
import qualified GHCJS.DOM.Element as Element
import GHCJS.DOM.EventM (EventM)
import GHCJS.DOM.NamedNodeMap as NNM
import GHCJS.DOM.Node (getFirstChild, getNodeName, removeChild)
import GHCJS.DOM.Types
       (liftJSM, JSM, IsHTMLElement, IsNode)
import qualified GHCJS.DOM.Types as DOM
import Reflex.Class
import Reflex.Dom.Builder.Class
import Reflex.Dom.Builder.Immediate
import Reflex.Dom.Widget.Basic
import Reflex.Host.Class
import Reflex.PerformEvent.Class
import Reflex.PostBuild.Class
import Reflex.TriggerEvent.Class

data ElConfig attrs = ElConfig
  { ElConfig attrs -> Maybe Text
_elConfig_namespace :: Maybe Text
  , ElConfig attrs -> attrs
_elConfig_attributes :: attrs
  }

instance attrs ~ Map Text Text => Default (ElConfig attrs) where
  def :: ElConfig attrs
def = ElConfig :: forall attrs. Maybe Text -> attrs -> ElConfig attrs
ElConfig
    { _elConfig_namespace :: Maybe Text
_elConfig_namespace = Maybe Text
forall a. Maybe a
Nothing
    , _elConfig_attributes :: attrs
_elConfig_attributes = attrs
forall a. Monoid a => a
mempty
    }

#ifdef USE_TEMPLATE_HASKELL
makeLenses ''ElConfig
#else
elConfig_namespace :: Lens' (ElConfig attrs1) (Maybe Text)
elConfig_namespace f (ElConfig a b) = (\a' -> ElConfig a' b) <$> f a
{-# INLINE elConfig_namespace #-}
elConfig_attributes :: Lens (ElConfig attrs1) (ElConfig attrs2) attrs1 attrs2
elConfig_attributes f (ElConfig a b) = (\b' -> ElConfig a b') <$> f b
{-# INLINE elConfig_attributes #-}
#endif

type MonadWidgetConstraints t m =
  ( DomBuilder t m
  , DomBuilderSpace m ~ GhcjsDomSpace
  , MonadFix m
  , MonadHold t m
  , MonadSample t (Performable m)
  , MonadReflexCreateTrigger t m
  , PostBuild t m
  , PerformEvent t m
  , MonadIO m
  , MonadIO (Performable m)
#ifndef ghcjs_HOST_OS
  , DOM.MonadJSM m
  , DOM.MonadJSM (Performable m)
#endif
  , TriggerEvent t m
  , HasJSContext m
  , HasJSContext (Performable m)
  , HasDocument m
  , MonadRef m
  , Ref m ~ Ref IO
  , MonadRef (Performable m)
  , Ref (Performable m) ~ Ref IO
  )

class MonadWidgetConstraints t m => MonadWidget t m
instance MonadWidgetConstraints t m => MonadWidget t m

type WidgetHost m = Performable m

type El = Element EventResult GhcjsDomSpace

addVoidAction :: MonadWidget t m => Event t (WidgetHost m ()) -> m ()
addVoidAction :: Event t (WidgetHost m ()) -> m ()
addVoidAction = Event t (WidgetHost m ()) -> m ()
forall t (m :: * -> *).
PerformEvent t m =>
Event t (Performable m ()) -> m ()
performEvent_

type AttributeMap = Map Text Text

buildElement :: (MonadWidget t m, Attributes m attrs t) => Text -> attrs -> m a -> m (RawElement (DomBuilderSpace m), a)
buildElement :: Text -> attrs -> m a -> m (RawElement (DomBuilderSpace m), a)
buildElement = Maybe Text
-> Text -> attrs -> m a -> m (RawElement (DomBuilderSpace m), a)
forall t (m :: * -> *) attrs a.
(MonadWidget t m, Attributes m attrs t) =>
Maybe Text
-> Text -> attrs -> m a -> m (RawElement (DomBuilderSpace m), a)
buildElementNS Maybe Text
forall a. Maybe a
Nothing

buildEmptyElement :: (MonadWidget t m, Attributes m attrs t) => Text -> attrs -> m (RawElement (DomBuilderSpace m))
buildEmptyElement :: Text -> attrs -> m (RawElement (DomBuilderSpace m))
buildEmptyElement elementTag :: Text
elementTag attrs :: attrs
attrs = (Element, ()) -> Element
forall a b. (a, b) -> a
fst ((Element, ()) -> Element) -> m (Element, ()) -> m Element
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Text
-> Text -> attrs -> m () -> m (RawElement (DomBuilderSpace m), ())
forall t (m :: * -> *) attrs a.
(MonadWidget t m, Attributes m attrs t) =>
Maybe Text
-> Text -> attrs -> m a -> m (RawElement (DomBuilderSpace m), a)
buildElementNS Maybe Text
forall a. Maybe a
Nothing Text
elementTag attrs
attrs m ()
forall (m :: * -> *). Monad m => m ()
blank

buildEmptyElementNS :: (MonadWidget t m, Attributes m attrs t) => Maybe Text -> Text -> attrs -> m (RawElement (DomBuilderSpace m))
buildEmptyElementNS :: Maybe Text -> Text -> attrs -> m (RawElement (DomBuilderSpace m))
buildEmptyElementNS ns :: Maybe Text
ns elementTag :: Text
elementTag attrs :: attrs
attrs = (Element, ()) -> Element
forall a b. (a, b) -> a
fst ((Element, ()) -> Element) -> m (Element, ()) -> m Element
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Text
-> Text -> attrs -> m () -> m (RawElement (DomBuilderSpace m), ())
forall t (m :: * -> *) attrs a.
(MonadWidget t m, Attributes m attrs t) =>
Maybe Text
-> Text -> attrs -> m a -> m (RawElement (DomBuilderSpace m), a)
buildElementNS Maybe Text
ns Text
elementTag attrs
attrs m ()
forall (m :: * -> *). Monad m => m ()
blank

buildElementNS :: (MonadWidget t m, Attributes m attrs t) => Maybe Text -> Text -> attrs -> m a -> m (RawElement (DomBuilderSpace m), a)
buildElementNS :: Maybe Text
-> Text -> attrs -> m a -> m (RawElement (DomBuilderSpace m), a)
buildElementNS ns :: Maybe Text
ns elementTag :: Text
elementTag attrs :: attrs
attrs child :: m a
child = (Element EventResult GhcjsDomSpace t -> Element)
-> (Element EventResult GhcjsDomSpace t, a) -> (Element, a)
forall (a :: * -> * -> *) b c d.
Arrow a =>
a b c -> a (b, d) (c, d)
first Element EventResult GhcjsDomSpace t -> Element
forall (er :: EventTag -> *) k1 (d :: k1) k2 (t :: k2).
Element er d t -> RawElement d
_element_raw ((Element EventResult GhcjsDomSpace t, a) -> (Element, a))
-> m (Element EventResult GhcjsDomSpace t, a) -> m (Element, a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Text
-> Text
-> attrs
-> m a
-> m (Element EventResult (DomBuilderSpace m) t, a)
forall (m :: * -> *) attrs t a.
(Attributes m attrs t, MonadWidget t m) =>
Maybe Text
-> Text
-> attrs
-> m a
-> m (Element EventResult (DomBuilderSpace m) t, a)
buildElementInternal Maybe Text
ns Text
elementTag attrs
attrs m a
child

class Attributes m attrs t where
  buildElementInternal :: MonadWidget t m => Maybe Text -> Text -> attrs -> m a -> m (Element EventResult (DomBuilderSpace m) t, a)

instance Attributes m (Map Text Text) t where
  buildElementInternal :: Maybe Text
-> Text
-> Map Text Text
-> m a
-> m (Element EventResult (DomBuilderSpace m) t, a)
buildElementInternal ns :: Maybe Text
ns elementTag :: Text
elementTag attrs :: Map Text Text
attrs child :: m a
child = do
    let cfg :: ElementConfig EventResult t GhcjsDomSpace
cfg = ElementConfig EventResult t GhcjsDomSpace
forall a. Default a => a
def ElementConfig EventResult t GhcjsDomSpace
-> (ElementConfig EventResult t GhcjsDomSpace
    -> ElementConfig EventResult t GhcjsDomSpace)
-> ElementConfig EventResult t GhcjsDomSpace
forall a b. a -> (a -> b) -> b
& (Maybe Text -> Identity (Maybe Text))
-> ElementConfig EventResult t GhcjsDomSpace
-> Identity (ElementConfig EventResult t GhcjsDomSpace)
forall k1 k2 (er :: EventTag -> *) (t :: k1) (s :: k2).
Lens' (ElementConfig er t s) (Maybe Text)
elementConfig_namespace ((Maybe Text -> Identity (Maybe Text))
 -> ElementConfig EventResult t GhcjsDomSpace
 -> Identity (ElementConfig EventResult t GhcjsDomSpace))
-> Maybe Text
-> ElementConfig EventResult t GhcjsDomSpace
-> ElementConfig EventResult t GhcjsDomSpace
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Maybe Text
ns
    Text
-> m a
-> ElementConfig EventResult t (DomBuilderSpace m)
-> m (Element EventResult (DomBuilderSpace m) t, a)
forall t (m :: * -> *) a (er :: EventTag -> *).
MonadWidget t m =>
Text
-> m a
-> ElementConfig er t (DomBuilderSpace m)
-> m (Element er (DomBuilderSpace m) t, a)
buildElementCommon Text
elementTag m a
child (ElementConfig EventResult t GhcjsDomSpace
 -> m (Element EventResult GhcjsDomSpace t, a))
-> m (ElementConfig EventResult t GhcjsDomSpace)
-> m (Element EventResult GhcjsDomSpace t, a)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Map Text Text
-> ElementConfig EventResult t (DomBuilderSpace m)
-> m (ElementConfig EventResult t (DomBuilderSpace m))
forall (m :: * -> *) (er :: EventTag -> *) t.
Applicative m =>
Map Text Text
-> ElementConfig er t (DomBuilderSpace m)
-> m (ElementConfig er t (DomBuilderSpace m))
addStaticAttributes Map Text Text
attrs ElementConfig EventResult t (DomBuilderSpace m)
ElementConfig EventResult t GhcjsDomSpace
cfg

addStaticAttributes :: Applicative m => Map Text Text -> ElementConfig er t (DomBuilderSpace m) -> m (ElementConfig er t (DomBuilderSpace m))
addStaticAttributes :: Map Text Text
-> ElementConfig er t (DomBuilderSpace m)
-> m (ElementConfig er t (DomBuilderSpace m))
addStaticAttributes attrs :: Map Text Text
attrs cfg :: ElementConfig er t (DomBuilderSpace m)
cfg = do
  let initialAttrs :: Map AttributeName Text
initialAttrs = [(AttributeName, Text)] -> Map AttributeName Text
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList ([(AttributeName, Text)] -> Map AttributeName Text)
-> [(AttributeName, Text)] -> Map AttributeName Text
forall a b. (a -> b) -> a -> b
$ (Text -> AttributeName) -> (Text, Text) -> (AttributeName, Text)
forall (a :: * -> * -> *) b c d.
Arrow a =>
a b c -> a (b, d) (c, d)
first (Maybe Text -> Text -> AttributeName
AttributeName Maybe Text
forall a. Maybe a
Nothing) ((Text, Text) -> (AttributeName, Text))
-> [(Text, Text)] -> [(AttributeName, Text)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Map Text Text -> [(Text, Text)]
forall k a. Map k a -> [(k, a)]
Map.toList Map Text Text
attrs
  ElementConfig er t (DomBuilderSpace m)
-> m (ElementConfig er t (DomBuilderSpace m))
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ElementConfig er t (DomBuilderSpace m)
 -> m (ElementConfig er t (DomBuilderSpace m)))
-> ElementConfig er t (DomBuilderSpace m)
-> m (ElementConfig er t (DomBuilderSpace m))
forall a b. (a -> b) -> a -> b
$ ElementConfig er t (DomBuilderSpace m)
cfg ElementConfig er t (DomBuilderSpace m)
-> (ElementConfig er t (DomBuilderSpace m)
    -> ElementConfig er t (DomBuilderSpace m))
-> ElementConfig er t (DomBuilderSpace m)
forall a b. a -> (a -> b) -> b
& (Map AttributeName Text -> Identity (Map AttributeName Text))
-> ElementConfig er t (DomBuilderSpace m)
-> Identity (ElementConfig er t (DomBuilderSpace m))
forall k1 k2 (er :: EventTag -> *) (t :: k1) (s :: k2).
Lens' (ElementConfig er t s) (Map AttributeName Text)
elementConfig_initialAttributes ((Map AttributeName Text -> Identity (Map AttributeName Text))
 -> ElementConfig er t (DomBuilderSpace m)
 -> Identity (ElementConfig er t (DomBuilderSpace m)))
-> Map AttributeName Text
-> ElementConfig er t (DomBuilderSpace m)
-> ElementConfig er t (DomBuilderSpace m)
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Map AttributeName Text
initialAttrs

instance PostBuild t m => Attributes m (Dynamic t (Map Text Text)) t where
  buildElementInternal :: Maybe Text
-> Text
-> Dynamic t (Map Text Text)
-> m a
-> m (Element EventResult (DomBuilderSpace m) t, a)
buildElementInternal ns :: Maybe Text
ns elementTag :: Text
elementTag attrs :: Dynamic t (Map Text Text)
attrs child :: m a
child = do
    let cfg :: ElementConfig EventResult t GhcjsDomSpace
cfg = ElementConfig EventResult t GhcjsDomSpace
forall a. Default a => a
def ElementConfig EventResult t GhcjsDomSpace
-> (ElementConfig EventResult t GhcjsDomSpace
    -> ElementConfig EventResult t GhcjsDomSpace)
-> ElementConfig EventResult t GhcjsDomSpace
forall a b. a -> (a -> b) -> b
& (Maybe Text -> Identity (Maybe Text))
-> ElementConfig EventResult t GhcjsDomSpace
-> Identity (ElementConfig EventResult t GhcjsDomSpace)
forall k1 k2 (er :: EventTag -> *) (t :: k1) (s :: k2).
Lens' (ElementConfig er t s) (Maybe Text)
elementConfig_namespace ((Maybe Text -> Identity (Maybe Text))
 -> ElementConfig EventResult t GhcjsDomSpace
 -> Identity (ElementConfig EventResult t GhcjsDomSpace))
-> Maybe Text
-> ElementConfig EventResult t GhcjsDomSpace
-> ElementConfig EventResult t GhcjsDomSpace
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Maybe Text
ns
    Text
-> m a
-> ElementConfig EventResult t (DomBuilderSpace m)
-> m (Element EventResult (DomBuilderSpace m) t, a)
forall t (m :: * -> *) a (er :: EventTag -> *).
MonadWidget t m =>
Text
-> m a
-> ElementConfig er t (DomBuilderSpace m)
-> m (Element er (DomBuilderSpace m) t, a)
buildElementCommon Text
elementTag m a
child (ElementConfig EventResult t GhcjsDomSpace
 -> m (Element EventResult GhcjsDomSpace t, a))
-> m (ElementConfig EventResult t GhcjsDomSpace)
-> m (Element EventResult GhcjsDomSpace t, a)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Dynamic t (Map Text Text)
-> ElementConfig EventResult t (DomBuilderSpace m)
-> m (ElementConfig EventResult t (DomBuilderSpace m))
forall t (m :: * -> *) (er :: EventTag -> *).
PostBuild t m =>
Dynamic t (Map Text Text)
-> ElementConfig er t (DomBuilderSpace m)
-> m (ElementConfig er t (DomBuilderSpace m))
addDynamicAttributes Dynamic t (Map Text Text)
attrs ElementConfig EventResult t (DomBuilderSpace m)
ElementConfig EventResult t GhcjsDomSpace
cfg

addDynamicAttributes :: PostBuild t m => Dynamic t (Map Text Text) -> ElementConfig er t (DomBuilderSpace m) -> m (ElementConfig er t (DomBuilderSpace m))
addDynamicAttributes :: Dynamic t (Map Text Text)
-> ElementConfig er t (DomBuilderSpace m)
-> m (ElementConfig er t (DomBuilderSpace m))
addDynamicAttributes attrs :: Dynamic t (Map Text Text)
attrs cfg :: ElementConfig er t (DomBuilderSpace m)
cfg = do
  Event t (Map Text (Maybe Text))
modifyAttrs <- Dynamic t (Map Text Text) -> m (Event t (Map Text (Maybe Text)))
forall k t (m :: * -> *).
(Ord k, PostBuild t m) =>
Dynamic t (Map k Text) -> m (Event t (Map k (Maybe Text)))
dynamicAttributesToModifyAttributes Dynamic t (Map Text Text)
attrs
  ElementConfig er t (DomBuilderSpace m)
-> m (ElementConfig er t (DomBuilderSpace m))
forall (m :: * -> *) a. Monad m => a -> m a
return (ElementConfig er t (DomBuilderSpace m)
 -> m (ElementConfig er t (DomBuilderSpace m)))
-> ElementConfig er t (DomBuilderSpace m)
-> m (ElementConfig er t (DomBuilderSpace m))
forall a b. (a -> b) -> a -> b
$ ElementConfig er t (DomBuilderSpace m)
cfg ElementConfig er t (DomBuilderSpace m)
-> (ElementConfig er t (DomBuilderSpace m)
    -> ElementConfig er t (DomBuilderSpace m))
-> ElementConfig er t (DomBuilderSpace m)
forall a b. a -> (a -> b) -> b
& (Event t (Map AttributeName (Maybe Text))
 -> Identity (Event t (Map AttributeName (Maybe Text))))
-> ElementConfig er t (DomBuilderSpace m)
-> Identity (ElementConfig er t (DomBuilderSpace m))
forall k1 k2 (t :: k1) (er :: EventTag -> *) (m :: k2).
Reflex t =>
Lens'
  (ElementConfig er t m) (Event t (Map AttributeName (Maybe Text)))
elementConfig_modifyAttributes ((Event t (Map AttributeName (Maybe Text))
  -> Identity (Event t (Map AttributeName (Maybe Text))))
 -> ElementConfig er t (DomBuilderSpace m)
 -> Identity (ElementConfig er t (DomBuilderSpace m)))
-> Event t (Map AttributeName (Maybe Text))
-> ElementConfig er t (DomBuilderSpace m)
-> ElementConfig er t (DomBuilderSpace m)
forall s t a b. ASetter s t a b -> b -> s -> t
.~ (Map Text (Maybe Text) -> Map AttributeName (Maybe Text))
-> Event t (Map Text (Maybe Text))
-> Event t (Map AttributeName (Maybe Text))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Map Text (Maybe Text) -> Map AttributeName (Maybe Text)
forall v. Map Text v -> Map AttributeName v
mapKeysToAttributeName Event t (Map Text (Maybe Text))
modifyAttrs

buildElementCommon :: MonadWidget t m => Text -> m a -> ElementConfig er t (DomBuilderSpace m) -> m (Element er (DomBuilderSpace m) t, a)
buildElementCommon :: Text
-> m a
-> ElementConfig er t (DomBuilderSpace m)
-> m (Element er (DomBuilderSpace m) t, a)
buildElementCommon elementTag :: Text
elementTag child :: m a
child cfg :: ElementConfig er t (DomBuilderSpace m)
cfg = Text
-> ElementConfig er t (DomBuilderSpace m)
-> m a
-> m (Element er (DomBuilderSpace m) t, a)
forall t (m :: * -> *) (er :: EventTag -> *) a.
DomBuilder t m =>
Text
-> ElementConfig er t (DomBuilderSpace m)
-> m a
-> m (Element er (DomBuilderSpace m) t, a)
element Text
elementTag ElementConfig er t (DomBuilderSpace m)
cfg m a
child


onEventName :: IsHTMLElement e => EventName en -> e -> EventM e (EventType en) () -> JSM (JSM ())
onEventName :: EventName en -> e -> EventM e (EventType en) () -> JSM (JSM ())
onEventName = EventName en -> e -> EventM e (EventType en) () -> JSM (JSM ())
forall e (en :: EventTag).
IsElement e =>
EventName en -> e -> EventM e (EventType en) () -> JSM (JSM ())
elementOnEventName

schedulePostBuild :: (PostBuild t m, PerformEvent t m) => WidgetHost m () -> m ()
schedulePostBuild :: WidgetHost m () -> m ()
schedulePostBuild w :: WidgetHost m ()
w = do
  Event t ()
postBuild <- m (Event t ())
forall t (m :: * -> *). PostBuild t m => m (Event t ())
getPostBuild
  Event t (WidgetHost m ()) -> m ()
forall t (m :: * -> *).
PerformEvent t m =>
Event t (Performable m ()) -> m ()
performEvent_ (Event t (WidgetHost m ()) -> m ())
-> Event t (WidgetHost m ()) -> m ()
forall a b. (a -> b) -> a -> b
$ WidgetHost m ()
w WidgetHost m () -> Event t () -> Event t (WidgetHost m ())
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Event t ()
postBuild

text' :: MonadWidget t m => Text -> m DOM.Text
text' :: Text -> m Text
text' s :: Text
s = TextNode GhcjsDomSpace t -> Text
forall k1 (d :: k1) k2 (t :: k2). TextNode d t -> RawTextNode d
_textNode_raw (TextNode GhcjsDomSpace t -> Text)
-> m (TextNode GhcjsDomSpace t) -> m Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TextNodeConfig t -> m (TextNode (DomBuilderSpace m) t)
forall t (m :: * -> *).
DomBuilder t m =>
TextNodeConfig t -> m (TextNode (DomBuilderSpace m) t)
textNode (TextNodeConfig t
forall a. Default a => a
def TextNodeConfig t
-> (TextNodeConfig t -> TextNodeConfig t) -> TextNodeConfig t
forall a b. a -> (a -> b) -> b
& (Text -> Identity Text)
-> TextNodeConfig t -> Identity (TextNodeConfig t)
forall k (t :: k). Lens' (TextNodeConfig t) Text
textNodeConfig_initialContents ((Text -> Identity Text)
 -> TextNodeConfig t -> Identity (TextNodeConfig t))
-> Text -> TextNodeConfig t -> TextNodeConfig t
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Text
s)

instance HasAttributes (ElConfig attrs) where
  type Attrs (ElConfig attrs) = attrs
  attributes :: (Attrs (ElConfig attrs) -> f (Attrs (ElConfig attrs)))
-> ElConfig attrs -> f (ElConfig attrs)
attributes = (Attrs (ElConfig attrs) -> f (Attrs (ElConfig attrs)))
-> ElConfig attrs -> f (ElConfig attrs)
forall attrs attrs.
Lens (ElConfig attrs) (ElConfig attrs) attrs attrs
elConfig_attributes

instance HasNamespace (ElConfig attrs) where
  namespace :: (Maybe Text -> f (Maybe Text))
-> ElConfig attrs -> f (ElConfig attrs)
namespace = (Maybe Text -> f (Maybe Text))
-> ElConfig attrs -> f (ElConfig attrs)
forall attrs. Lens' (ElConfig attrs) (Maybe Text)
elConfig_namespace

elWith :: (MonadWidget t m, Attributes m attrs t) => Text -> ElConfig attrs -> m a -> m a
elWith :: Text -> ElConfig attrs -> m a -> m a
elWith elementTag :: Text
elementTag cfg :: ElConfig attrs
cfg child :: m a
child = (Element EventResult GhcjsDomSpace t, a) -> a
forall a b. (a, b) -> b
snd ((Element EventResult GhcjsDomSpace t, a) -> a)
-> m (Element EventResult GhcjsDomSpace t, a) -> m a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text
-> ElConfig attrs
-> m a
-> m (Element EventResult (DomBuilderSpace m) t, a)
forall t (m :: * -> *) attrs a.
(MonadWidget t m, Attributes m attrs t) =>
Text
-> ElConfig attrs
-> m a
-> m (Element EventResult (DomBuilderSpace m) t, a)
elWith' Text
elementTag ElConfig attrs
cfg m a
child

elWith' :: (MonadWidget t m, Attributes m attrs t) => Text -> ElConfig attrs -> m a -> m (Element EventResult (DomBuilderSpace m) t, a)
elWith' :: Text
-> ElConfig attrs
-> m a
-> m (Element EventResult (DomBuilderSpace m) t, a)
elWith' elementTag :: Text
elementTag cfg :: ElConfig attrs
cfg = Maybe Text
-> Text
-> attrs
-> m a
-> m (Element EventResult (DomBuilderSpace m) t, a)
forall (m :: * -> *) attrs t a.
(Attributes m attrs t, MonadWidget t m) =>
Maybe Text
-> Text
-> attrs
-> m a
-> m (Element EventResult (DomBuilderSpace m) t, a)
buildElementInternal (ElConfig attrs
cfg ElConfig attrs
-> Getting (Maybe Text) (ElConfig attrs) (Maybe Text) -> Maybe Text
forall s a. s -> Getting a s a -> a
^. Getting (Maybe Text) (ElConfig attrs) (Maybe Text)
forall a. HasNamespace a => Lens' a (Maybe Text)
namespace) Text
elementTag (attrs -> m a -> m (Element EventResult (DomBuilderSpace m) t, a))
-> attrs -> m a -> m (Element EventResult (DomBuilderSpace m) t, a)
forall a b. (a -> b) -> a -> b
$ ElConfig attrs
cfg ElConfig attrs -> Getting attrs (ElConfig attrs) attrs -> attrs
forall s a. s -> Getting a s a -> a
^. Getting attrs (ElConfig attrs) attrs
forall a. HasAttributes a => Lens' a (Attrs a)
attributes

emptyElWith :: (MonadWidget t m, Attributes m attrs t) => Text -> ElConfig attrs -> m ()
emptyElWith :: Text -> ElConfig attrs -> m ()
emptyElWith elementTag :: Text
elementTag cfg :: ElConfig attrs
cfg = m (Element EventResult GhcjsDomSpace t) -> m ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (m (Element EventResult GhcjsDomSpace t) -> m ())
-> m (Element EventResult GhcjsDomSpace t) -> m ()
forall a b. (a -> b) -> a -> b
$ Text
-> ElConfig attrs -> m (Element EventResult (DomBuilderSpace m) t)
forall t (m :: * -> *) attrs.
(MonadWidget t m, Attributes m attrs t) =>
Text
-> ElConfig attrs -> m (Element EventResult (DomBuilderSpace m) t)
emptyElWith' Text
elementTag ElConfig attrs
cfg

emptyElWith' :: (MonadWidget t m, Attributes m attrs t) => Text -> ElConfig attrs -> m (Element EventResult (DomBuilderSpace m) t)
emptyElWith' :: Text
-> ElConfig attrs -> m (Element EventResult (DomBuilderSpace m) t)
emptyElWith' elementTag :: Text
elementTag cfg :: ElConfig attrs
cfg = ((Element EventResult GhcjsDomSpace t, ())
 -> Element EventResult GhcjsDomSpace t)
-> m (Element EventResult GhcjsDomSpace t, ())
-> m (Element EventResult GhcjsDomSpace t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Element EventResult GhcjsDomSpace t, ())
-> Element EventResult GhcjsDomSpace t
forall a b. (a, b) -> a
fst (m (Element EventResult GhcjsDomSpace t, ())
 -> m (Element EventResult (DomBuilderSpace m) t))
-> m (Element EventResult GhcjsDomSpace t, ())
-> m (Element EventResult (DomBuilderSpace m) t)
forall a b. (a -> b) -> a -> b
$ Text
-> ElConfig attrs
-> m ()
-> m (Element EventResult (DomBuilderSpace m) t, ())
forall t (m :: * -> *) attrs a.
(MonadWidget t m, Attributes m attrs t) =>
Text
-> ElConfig attrs
-> m a
-> m (Element EventResult (DomBuilderSpace m) t, a)
elWith' Text
elementTag ElConfig attrs
cfg (m () -> m (Element EventResult GhcjsDomSpace t, ()))
-> m () -> m (Element EventResult GhcjsDomSpace t, ())
forall a b. (a -> b) -> a -> b
$ () -> m ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

{-# DEPRECATED _el_clicked "Use 'domEvent Click' instead" #-}
_el_clicked :: Reflex t => Element EventResult d t -> Event t ()
_el_clicked :: Element EventResult d t -> Event t ()
_el_clicked = EventName 'ClickTag
-> Element EventResult d t
-> Event t (DomEventType (Element EventResult d t) 'ClickTag)
forall k (t :: k) target (eventName :: EventTag).
HasDomEvent t target eventName =>
EventName eventName
-> target -> Event t (DomEventType target eventName)
domEvent EventName 'ClickTag
Click

{-# DEPRECATED _el_element "Use '_element_raw' instead" #-}
_el_element :: El t -> RawElement GhcjsDomSpace
_el_element :: El t -> RawElement GhcjsDomSpace
_el_element = El t -> RawElement GhcjsDomSpace
forall (er :: EventTag -> *) k1 (d :: k1) k2 (t :: k2).
Element er d t -> RawElement d
_element_raw

{-# DEPRECATED _el_events "Use '_element_events' instead; or, if possible, use 'domEvent' instead to retrieve a particular event" #-}
_el_events :: Element er d t -> EventSelector t (WrapArg er EventName)
_el_events :: Element er d t -> EventSelector t (WrapArg er EventName)
_el_events = Element er d t -> EventSelector t (WrapArg er EventName)
forall (er :: EventTag -> *) k1 (d :: k1) k2 (t :: k2).
Element er d t -> EventSelector t (WrapArg er EventName)
_element_events

{-# DEPRECATED _el_keypress "Use 'domEvent Keypress' instead" #-}
_el_keypress :: Reflex t => El t -> Event t Word
_el_keypress :: El t -> Event t Word
_el_keypress = EventName 'KeypressTag
-> El t -> Event t (DomEventType (El t) 'KeypressTag)
forall k (t :: k) target (eventName :: EventTag).
HasDomEvent t target eventName =>
EventName eventName
-> target -> Event t (DomEventType target eventName)
domEvent EventName 'KeypressTag
Keypress

{-# DEPRECATED _el_scrolled "Use 'domEvent Scroll' instead" #-}
_el_scrolled :: Reflex t => El t -> Event t Double
_el_scrolled :: El t -> Event t Double
_el_scrolled = EventName 'ScrollTag
-> El t -> Event t (DomEventType (El t) 'ScrollTag)
forall k (t :: k) target (eventName :: EventTag).
HasDomEvent t target eventName =>
EventName eventName
-> target -> Event t (DomEventType target eventName)
domEvent EventName 'ScrollTag
Scroll

wrapElement :: forall t m. MonadWidget t m => (forall en. DOM.HTMLElement -> EventName en -> EventM DOM.Element (EventType en) (Maybe (EventResult en))) -> DOM.HTMLElement -> m (El t)
wrapElement :: (forall (en :: EventTag).
 HTMLElement
 -> EventName en
 -> EventM Element (EventType en) (Maybe (EventResult en)))
-> HTMLElement -> m (El t)
wrapElement eh :: forall (en :: EventTag).
HTMLElement
-> EventName en
-> EventM Element (EventType en) (Maybe (EventResult en))
eh e :: HTMLElement
e = do
  let h :: (EventName en, GhcjsDomEvent en) -> JSM (Maybe (EventResult en))
      h :: (EventName en, GhcjsDomEvent en) -> JSM (Maybe (EventResult en))
h (en :: EventName en
en, GhcjsDomEvent evt :: EventType en
evt) = ReaderT (EventType en) DOM (Maybe (EventResult en))
-> EventType en -> JSM (Maybe (EventResult en))
forall r (m :: * -> *) a. ReaderT r m a -> r -> m a
runReaderT (HTMLElement
-> EventName en
-> ReaderT (EventType en) DOM (Maybe (EventResult en))
forall (en :: EventTag).
HTMLElement
-> EventName en
-> EventM Element (EventType en) (Maybe (EventResult en))
eh HTMLElement
e EventName en
en) EventType en
evt
  RawElement (DomBuilderSpace m)
-> RawElementConfig EventResult t (DomBuilderSpace m)
-> m (Element EventResult (DomBuilderSpace m) t)
forall t (m :: * -> *) (er :: EventTag -> *).
DomBuilder t m =>
RawElement (DomBuilderSpace m)
-> RawElementConfig er t (DomBuilderSpace m)
-> m (Element er (DomBuilderSpace m) t)
wrapRawElement (HTMLElement -> Element
forall o. IsElement o => o -> Element
DOM.toElement HTMLElement
e) (RawElementConfig EventResult t (DomBuilderSpace m) -> m (El t))
-> RawElementConfig EventResult t (DomBuilderSpace m) -> m (El t)
forall a b. (a -> b) -> a -> b
$ (RawElementConfig EventResult t (DomBuilderSpace m)
forall a. Default a => a
def :: RawElementConfig EventResult t (DomBuilderSpace m))
    { _rawElementConfig_eventSpec :: EventSpec GhcjsDomSpace EventResult
_rawElementConfig_eventSpec = GhcjsEventSpec EventResult
forall a. Default a => a
def
        { _ghcjsEventSpec_handler :: GhcjsEventHandler EventResult
_ghcjsEventSpec_handler = (forall (en :: EventTag).
 (EventName en, GhcjsDomEvent en) -> JSM (Maybe (EventResult en)))
-> GhcjsEventHandler EventResult
forall (er :: EventTag -> *).
(forall (en :: EventTag).
 (EventName en, GhcjsDomEvent en) -> JSM (Maybe (er en)))
-> GhcjsEventHandler er
GhcjsEventHandler forall (en :: EventTag).
(EventName en, GhcjsDomEvent en) -> JSM (Maybe (EventResult en))
h
        }
    }

unsafePlaceElement :: MonadWidget t m => DOM.HTMLElement -> m (Element EventResult (DomBuilderSpace m) t)
unsafePlaceElement :: HTMLElement -> m (Element EventResult (DomBuilderSpace m) t)
unsafePlaceElement e :: HTMLElement
e = do
  RawElement (DomBuilderSpace m) -> m ()
forall t (m :: * -> *).
DomBuilder t m =>
RawElement (DomBuilderSpace m) -> m ()
placeRawElement (RawElement (DomBuilderSpace m) -> m ())
-> RawElement (DomBuilderSpace m) -> m ()
forall a b. (a -> b) -> a -> b
$ HTMLElement -> Element
forall o. IsElement o => o -> Element
DOM.toElement HTMLElement
e
  RawElement (DomBuilderSpace m)
-> RawElementConfig EventResult t (DomBuilderSpace m)
-> m (Element EventResult (DomBuilderSpace m) t)
forall t (m :: * -> *) (er :: EventTag -> *).
DomBuilder t m =>
RawElement (DomBuilderSpace m)
-> RawElementConfig er t (DomBuilderSpace m)
-> m (Element er (DomBuilderSpace m) t)
wrapRawElement (HTMLElement -> Element
forall o. IsElement o => o -> Element
DOM.toElement HTMLElement
e) RawElementConfig EventResult t (DomBuilderSpace m)
forall a. Default a => a
def

namedNodeMapGetNames :: DOM.NamedNodeMap -> JSM (Set Text)
namedNodeMapGetNames :: NamedNodeMap -> JSM (Set Text)
namedNodeMapGetNames self :: NamedNodeMap
self = do
  Word
l <- NamedNodeMap -> JSM Word
forall (m :: * -> *). MonadDOM m => NamedNodeMap -> m Word
NNM.getLength NamedNodeMap
self
  [Text] -> Set Text
forall a. Ord a => [a] -> Set a
Set.fromList ([Text] -> Set Text) -> JSM [Text] -> JSM (Set Text)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Word] -> (Word -> JSM Text) -> JSM [Text]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
t a -> (a -> m b) -> m (t b)
forM (Int -> [Word] -> [Word]
forall a. Int -> [a] -> [a]
take (Word -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word
l) [0..]) (
    NamedNodeMap -> Word -> JSM Attr
forall (m :: * -> *). MonadDOM m => NamedNodeMap -> Word -> m Attr
NNM.itemUnchecked NamedNodeMap
self (Word -> JSM Attr) -> (Attr -> JSM Text) -> Word -> JSM Text
forall (m :: * -> *) a b c.
Monad m =>
(a -> m b) -> (b -> m c) -> a -> m c
>=> Attr -> JSM Text
forall (m :: * -> *) self result.
(MonadDOM m, IsNode self, FromJSString result) =>
self -> m result
getNodeName)

nodeClear :: IsNode self => self -> JSM ()
nodeClear :: self -> JSM ()
nodeClear n :: self
n = do
  Maybe Node
mfc <- self -> JSM (Maybe Node)
forall (m :: * -> *) self.
(MonadDOM m, IsNode self) =>
self -> m (Maybe Node)
getFirstChild self
n
  case Maybe Node
mfc of
    Nothing -> () -> JSM ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
    Just fc :: Node
fc -> do
      Node
_ <- self -> Node -> JSM Node
forall (m :: * -> *) self child.
(MonadDOM m, IsNode self, IsNode child) =>
self -> child -> m Node
removeChild self
n Node
fc
      self -> JSM ()
forall self. IsNode self => self -> JSM ()
nodeClear self
n

elStopPropagationNS :: forall t m en a. (MonadWidget t m) => Maybe Text -> Text -> EventName en -> m a -> m a
elStopPropagationNS :: Maybe Text -> Text -> EventName en -> m a -> m a
elStopPropagationNS ns :: Maybe Text
ns elementTag :: Text
elementTag en :: EventName en
en child :: m a
child = do
  let f :: GhcjsEventFilter er en
f = (GhcjsDomEvent en -> JSM (EventFlags, JSM (Maybe (er en))))
-> GhcjsEventFilter er en
forall (er :: EventTag -> *) (en :: EventTag).
(GhcjsDomEvent en -> JSM (EventFlags, JSM (Maybe (er en))))
-> GhcjsEventFilter er en
GhcjsEventFilter ((GhcjsDomEvent en -> JSM (EventFlags, JSM (Maybe (er en))))
 -> GhcjsEventFilter er en)
-> (GhcjsDomEvent en -> JSM (EventFlags, JSM (Maybe (er en))))
-> GhcjsEventFilter er en
forall a b. (a -> b) -> a -> b
$ \_ -> do
        (EventFlags, JSM (Maybe (er en)))
-> JSM (EventFlags, JSM (Maybe (er en)))
forall (m :: * -> *) a. Monad m => a -> m a
return (EventFlags
stopPropagation, Maybe (er en) -> JSM (Maybe (er en))
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe (er en)
forall a. Maybe a
Nothing)
      cfg :: ElementConfig EventResult t GhcjsDomSpace
cfg = (ElementConfig EventResult t (DomBuilderSpace m)
forall a. Default a => a
def :: ElementConfig EventResult t (DomBuilderSpace m))
        ElementConfig EventResult t GhcjsDomSpace
-> (ElementConfig EventResult t GhcjsDomSpace
    -> ElementConfig EventResult t GhcjsDomSpace)
-> ElementConfig EventResult t GhcjsDomSpace
forall a b. a -> (a -> b) -> b
& (Maybe Text -> Identity (Maybe Text))
-> ElementConfig EventResult t GhcjsDomSpace
-> Identity (ElementConfig EventResult t GhcjsDomSpace)
forall a. HasNamespace a => Lens' a (Maybe Text)
namespace ((Maybe Text -> Identity (Maybe Text))
 -> ElementConfig EventResult t GhcjsDomSpace
 -> Identity (ElementConfig EventResult t GhcjsDomSpace))
-> Maybe Text
-> ElementConfig EventResult t GhcjsDomSpace
-> ElementConfig EventResult t GhcjsDomSpace
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Maybe Text
ns
        ElementConfig EventResult t GhcjsDomSpace
-> (ElementConfig EventResult t GhcjsDomSpace
    -> ElementConfig EventResult t GhcjsDomSpace)
-> ElementConfig EventResult t GhcjsDomSpace
forall a b. a -> (a -> b) -> b
& (GhcjsEventSpec EventResult
 -> Identity (GhcjsEventSpec EventResult))
-> ElementConfig EventResult t GhcjsDomSpace
-> Identity (ElementConfig EventResult t GhcjsDomSpace)
forall k1 k2 k3 (er :: EventTag -> *) (t :: k1) (s :: k2)
       (er2 :: EventTag -> *) (s2 :: k3).
Lens
  (ElementConfig er t s)
  (ElementConfig er2 t s2)
  (EventSpec s er)
  (EventSpec s2 er2)
elementConfig_eventSpec ((GhcjsEventSpec EventResult
  -> Identity (GhcjsEventSpec EventResult))
 -> ElementConfig EventResult t GhcjsDomSpace
 -> Identity (ElementConfig EventResult t GhcjsDomSpace))
-> ((DMap EventName (GhcjsEventFilter EventResult)
     -> Identity (DMap EventName (GhcjsEventFilter EventResult)))
    -> GhcjsEventSpec EventResult
    -> Identity (GhcjsEventSpec EventResult))
-> (DMap EventName (GhcjsEventFilter EventResult)
    -> Identity (DMap EventName (GhcjsEventFilter EventResult)))
-> ElementConfig EventResult t GhcjsDomSpace
-> Identity (ElementConfig EventResult t GhcjsDomSpace)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (DMap EventName (GhcjsEventFilter EventResult)
 -> Identity (DMap EventName (GhcjsEventFilter EventResult)))
-> GhcjsEventSpec EventResult
-> Identity (GhcjsEventSpec EventResult)
forall (er :: EventTag -> *).
Lens' (GhcjsEventSpec er) (DMap EventName (GhcjsEventFilter er))
ghcjsEventSpec_filters ((DMap EventName (GhcjsEventFilter EventResult)
  -> Identity (DMap EventName (GhcjsEventFilter EventResult)))
 -> ElementConfig EventResult t GhcjsDomSpace
 -> Identity (ElementConfig EventResult t GhcjsDomSpace))
-> (DMap EventName (GhcjsEventFilter EventResult)
    -> DMap EventName (GhcjsEventFilter EventResult))
-> ElementConfig EventResult t GhcjsDomSpace
-> ElementConfig EventResult t GhcjsDomSpace
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
%~ EventName en
-> GhcjsEventFilter EventResult en
-> DMap EventName (GhcjsEventFilter EventResult)
-> DMap EventName (GhcjsEventFilter EventResult)
forall k1 (k2 :: k1 -> *) (f :: k1 -> *) (v :: k1).
GCompare k2 =>
k2 v -> f v -> DMap k2 f -> DMap k2 f
DMap.insert EventName en
en GhcjsEventFilter EventResult en
forall (er :: EventTag -> *) (en :: EventTag).
GhcjsEventFilter er en
f
  (Element EventResult GhcjsDomSpace t, a) -> a
forall a b. (a, b) -> b
snd ((Element EventResult GhcjsDomSpace t, a) -> a)
-> m (Element EventResult GhcjsDomSpace t, a) -> m a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text
-> ElementConfig EventResult t (DomBuilderSpace m)
-> m a
-> m (Element EventResult (DomBuilderSpace m) t, a)
forall t (m :: * -> *) (er :: EventTag -> *) a.
DomBuilder t m =>
Text
-> ElementConfig er t (DomBuilderSpace m)
-> m a
-> m (Element er (DomBuilderSpace m) t, a)
element Text
elementTag ElementConfig EventResult t (DomBuilderSpace m)
ElementConfig EventResult t GhcjsDomSpace
cfg m a
child

elDynHtmlAttr' :: (DOM.MonadJSM m, MonadWidget t m) => Text -> Map Text Text -> Dynamic t Text -> m (Element EventResult GhcjsDomSpace t)
elDynHtmlAttr' :: Text
-> Map Text Text
-> Dynamic t Text
-> m (Element EventResult GhcjsDomSpace t)
elDynHtmlAttr' elementTag :: Text
elementTag attrs :: Map Text Text
attrs html :: Dynamic t Text
html = do
  let cfg :: ElementConfig EventResult t GhcjsDomSpace
cfg = ElementConfig EventResult t GhcjsDomSpace
forall a. Default a => a
def ElementConfig EventResult t GhcjsDomSpace
-> (ElementConfig EventResult t GhcjsDomSpace
    -> ElementConfig EventResult t GhcjsDomSpace)
-> ElementConfig EventResult t GhcjsDomSpace
forall a b. a -> (a -> b) -> b
& (Map AttributeName Text -> Identity (Map AttributeName Text))
-> ElementConfig EventResult t GhcjsDomSpace
-> Identity (ElementConfig EventResult t GhcjsDomSpace)
forall a. InitialAttributes a => Lens' a (Map AttributeName Text)
initialAttributes ((Map AttributeName Text -> Identity (Map AttributeName Text))
 -> ElementConfig EventResult t GhcjsDomSpace
 -> Identity (ElementConfig EventResult t GhcjsDomSpace))
-> Map AttributeName Text
-> ElementConfig EventResult t GhcjsDomSpace
-> ElementConfig EventResult t GhcjsDomSpace
forall s t a b. ASetter s t a b -> b -> s -> t
.~ (Text -> AttributeName) -> Map Text Text -> Map AttributeName Text
forall k2 k1 a. Ord k2 => (k1 -> k2) -> Map k1 a -> Map k2 a
Map.mapKeys (Maybe Text -> Text -> AttributeName
AttributeName Maybe Text
forall a. Maybe a
Nothing) Map Text Text
attrs
  (e :: Element EventResult GhcjsDomSpace t
e, _) <- Text
-> ElementConfig EventResult t (DomBuilderSpace m)
-> m ()
-> m (Element EventResult (DomBuilderSpace m) t, ())
forall t (m :: * -> *) (er :: EventTag -> *) a.
DomBuilder t m =>
Text
-> ElementConfig er t (DomBuilderSpace m)
-> m a
-> m (Element er (DomBuilderSpace m) t, a)
element Text
elementTag ElementConfig EventResult t (DomBuilderSpace m)
ElementConfig EventResult t GhcjsDomSpace
cfg (m () -> m (Element EventResult GhcjsDomSpace t, ()))
-> m () -> m (Element EventResult GhcjsDomSpace t, ())
forall a b. (a -> b) -> a -> b
$ () -> m ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
  Event t ()
postBuild <- m (Event t ())
forall t (m :: * -> *). PostBuild t m => m (Event t ())
getPostBuild
  Event t (Performable m ()) -> m ()
forall t (m :: * -> *).
PerformEvent t m =>
Event t (Performable m ()) -> m ()
performEvent_ (Event t (Performable m ()) -> m ())
-> Event t (Performable m ()) -> m ()
forall a b. (a -> b) -> a -> b
$ JSM () -> Performable m ()
forall (m :: * -> *) a. MonadJSM m => JSM a -> m a
liftJSM (JSM () -> Performable m ())
-> (Text -> JSM ()) -> Text -> Performable m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Element -> Text -> JSM ()
forall (m :: * -> *) self val.
(MonadDOM m, IsElement self, ToJSString val) =>
self -> val -> m ()
Element.setInnerHTML (Element EventResult GhcjsDomSpace t -> RawElement GhcjsDomSpace
forall (er :: EventTag -> *) k1 (d :: k1) k2 (t :: k2).
Element er d t -> RawElement d
_element_raw Element EventResult GhcjsDomSpace t
e) (Text -> Performable m ())
-> Event t Text -> Event t (Performable m ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Event t Text] -> Event t Text
forall k (t :: k) a. Reflex t => [Event t a] -> Event t a
leftmost [Dynamic t Text -> Event t Text
forall k (t :: k) a. Reflex t => Dynamic t a -> Event t a
updated Dynamic t Text
html, Behavior t Text -> Event t () -> Event t Text
forall k (t :: k) b a.
Reflex t =>
Behavior t b -> Event t a -> Event t b
tag (Dynamic t Text -> Behavior t Text
forall k (t :: k) a. Reflex t => Dynamic t a -> Behavior t a
current Dynamic t Text
html) Event t ()
postBuild]
  Element EventResult GhcjsDomSpace t
-> m (Element EventResult GhcjsDomSpace t)
forall (m :: * -> *) a. Monad m => a -> m a
return Element EventResult GhcjsDomSpace t
e

elDynHtml' :: MonadWidget t m => Text -> Dynamic t Text -> m (Element EventResult GhcjsDomSpace t)
elDynHtml' :: Text -> Dynamic t Text -> m (Element EventResult GhcjsDomSpace t)
elDynHtml' elementTag :: Text
elementTag = Text
-> Map Text Text
-> Dynamic t Text
-> m (Element EventResult GhcjsDomSpace t)
forall (m :: * -> *) t.
(MonadJSM m, MonadWidget t m) =>
Text
-> Map Text Text
-> Dynamic t Text
-> m (Element EventResult GhcjsDomSpace t)
elDynHtmlAttr' Text
elementTag Map Text Text
forall a. Monoid a => a
mempty