on develop help sign in
Merge pull request #358 from jhartzell42/jimmy/hydration-namespace-bug
e2a9716John Ericson
cabal.projectnew file+1
@@ -0,0 +1 @@
1+packages: reflex-dom-core, reflex-dom
reflex-dom-core/ChangeLog.md+2−1
@@ -2,7 +2,8 @@
2
2
3## Unreleased
3## Unreleased
4
4
5−Support GHC 8.8.
5+* Support GHC 8.8.
6+* Fix attribute support for explicitly namespaced elements
6
7
7## 0.5.3
8## 0.5.3
8
9
reflex-dom-core/src/Reflex/Dom/Builder/Immediate.hs+5−10
@@ -141,7 +141,7 @@ import Data.Text (Text)
141import Foreign.JavaScript.Internal.Utils
141import Foreign.JavaScript.Internal.Utils
142import Foreign.JavaScript.TH
142import Foreign.JavaScript.TH
143import GHCJS.DOM.Document (Document, createDocumentFragment, createElement, createElementNS, createTextNode, createComment)
143import GHCJS.DOM.Document (Document, createDocumentFragment, createElement, createElementNS, createTextNode, createComment)
144−import GHCJS.DOM.Element (getScrollTop, removeAttribute, removeAttributeNS, setAttribute, setAttributeNS, hasAttribute, hasAttributeNS)
144+import GHCJS.DOM.Element (getScrollTop, removeAttribute, removeAttributeNS, setAttribute, setAttributeNS, hasAttribute)
145import GHCJS.DOM.EventM (EventM, event, on)
145import GHCJS.DOM.EventM (EventM, event, on)
146import GHCJS.DOM.KeyboardEvent as KeyboardEvent
146import GHCJS.DOM.KeyboardEvent as KeyboardEvent
147import GHCJS.DOM.MouseEvent
147import GHCJS.DOM.MouseEvent
@@ -767,15 +767,10 @@ hydrateElement elementTag cfg child = do
767 let skipAttr = "data-hydration-skip" :: DOM.JSString
767 let skipAttr = "data-hydration-skip" :: DOM.JSString
768 ssrAttr = "data-ssr" :: DOM.JSString
768 ssrAttr = "data-ssr" :: DOM.JSString
769 shouldSkip :: DOM.Element -> HydrationRunnerT t m Bool
769 shouldSkip :: DOM.Element -> HydrationRunnerT t m Bool
770− shouldSkip e = case cfg ^. namespace of
770+ shouldSkip e = do
771− Nothing -> do
772− skip <- hasAttribute e skipAttr
771+ skip <- hasAttribute e skipAttr
773− ssr <- hasAttribute e ssrAttr
772+ ssr <- hasAttribute e ssrAttr
774− pure $ skip || not ssr
775− Just ns -> do
776− skip <- hasAttributeNS e (Just ns) skipAttr
777− ssr <- hasAttributeNS e (Just ns) ssrAttr
778− pure $ skip || not ssr
773+ pure $ skip || not ssr
779 childDom <- liftIO $ readIORef childDelayedRef
774 childDom <- liftIO $ readIORef childDelayedRef
780 let rawCfg = extractRawElementConfig cfg
775 let rawCfg = extractRawElementConfig cfg
781 doc <- askDocument
776 doc <- askDocument
reflex-dom-core/test/hydration.hs+10
@@ -22,6 +22,7 @@
22
22
23import Prelude hiding (fail)
23import Prelude hiding (fail)
24import Control.Concurrent
24import Control.Concurrent
25+import Control.Lens.Operators
25import Control.Monad hiding (fail)
26import Control.Monad hiding (fail)
26import Control.Monad.Catch
27import Control.Monad.Catch
27import Control.Monad.Fail
28import Control.Monad.Fail
@@ -770,6 +771,15 @@ tests withDebugging wdConfig caps _selenium = do
770 prerender_ (pure ()) (liftIO $ trigger "Client")
771 prerender_ (pure ()) (liftIO $ trigger "Client")
771 textNode $ TextNodeConfig "Initial" $ Just e
772 textNode $ TextNodeConfig "Initial" $ Just e
772
773
774+ describe "namespaces" $ session' $ do
775+ it "dyn can be nested in namespaced widget" $ runWD $ do
776+ testWidget (pure ()) (checkTextInTag "svg" "one") $ do
777+ let svgRootCfg = def
778+ & (elementConfig_namespace ?~ "http://www.w3.org/2000/svg")
779+ & (elementConfig_initialAttributes .~ ("width" =: "100%" <> "height" =: "100%" <> "viewBox" =: "0 0 1536 2048"))
780+ void $ element "svg" svgRootCfg $ do
781+ dyn_ $ text "one" <$ pure ()
782+
773 describe "runWithReplace" $ session' $ do
783 describe "runWithReplace" $ session' $ do
774 it "works" $ runWD $ do
784 it "works" $ runWD $ do
775 replaceChan :: Chan Text <- liftIO newChan
785 replaceChan :: Chan Text <- liftIO newChan