mirror of https://github.com/status-im/reagent.git
No need to mount test divs to dom
This commit is contained in:
parent
36509f79ff
commit
e0b8bd337b
|
@ -24,23 +24,15 @@
|
|||
|
||||
(def rflush r/flush)
|
||||
|
||||
(defn add-test-div [name]
|
||||
(let [doc js/document
|
||||
body (.-body js/document)
|
||||
div (.createElement doc "div")]
|
||||
(.appendChild body div)
|
||||
div))
|
||||
|
||||
(defn with-mounted-component [comp f]
|
||||
(when isClient
|
||||
(let [div (add-test-div "_testreagent")]
|
||||
(let [div (.createElement js/document "div")]
|
||||
(try
|
||||
(let [c (r/render comp div)]
|
||||
(f c div))
|
||||
(finally
|
||||
(r/unmount-component-at-node div)
|
||||
(r/flush)
|
||||
(.removeChild (.-body js/document) div))))))
|
||||
(r/flush))))))
|
||||
|
||||
(defn found-in [re div]
|
||||
(let [res (.-innerHTML div)]
|
||||
|
|
|
@ -3,20 +3,15 @@
|
|||
[reagent.debug :refer-macros [dbg println log]]
|
||||
[reagent.core :as r]))
|
||||
|
||||
(defn add-test-div [name]
|
||||
(let [doc js/document
|
||||
body (.-body js/document)
|
||||
div (.createElement doc "div")]
|
||||
(.appendChild body div)
|
||||
div))
|
||||
|
||||
(defn with-mounted-component [comp f]
|
||||
(when r/is-client
|
||||
(let [div (add-test-div "_testreagent")]
|
||||
(let [comp (r/render comp div #(f comp div))]
|
||||
(let [div (.createElement js/document "div")]
|
||||
(try
|
||||
(let [c (r/render comp div)]
|
||||
(f c div))
|
||||
(finally
|
||||
(r/unmount-component-at-node div)
|
||||
(r/flush)
|
||||
(.removeChild (.-body js/document) div)))))
|
||||
(r/flush))))))
|
||||
|
||||
(defn found-in [re div]
|
||||
(let [res (.-innerHTML div)]
|
||||
|
|
Loading…
Reference in New Issue