Merge pull request #25 from Day8/inject-once

Only inject trace panel once
This commit is contained in:
Daniel Compton 2017-07-26 13:43:14 +12:00 committed by GitHub
commit 9a2419c284
1 changed files with 11 additions and 3 deletions

View File

@ -251,7 +251,15 @@
:subvis [subvis/render-subvis traces]
[render-traces])]]]))})))
(defn panel-div []
(let [id "--re-frame-trace--"
panel (.getElementById js/document id)]
(if panel
panel
(let [new-panel (.createElement js/document "div")]
(.setAttribute new-panel "id" id)
(.appendChild (.-body js/document) new-panel)
new-panel))))
(defn inject-devtools! []
(let [div (.createElement js/document "div")]
(.appendChild (.-body js/document) div)
(r/render [devtools] div)))
(r/render [devtools] (panel-div)))