Created
September 22, 2016 09:09
-
-
Save zehnpaard/e2e262cba2aa301b49b58ed556e36ce8 to your computer and use it in GitHub Desktop.
Function for dynamic reloading of css from clojurescript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Intended use: hot-loading changes to garden-generated css via figwheel | |
(defn load-css [css-text] | |
(let [current-style (js/document.getElementById "mystyle")] | |
(if current-style | |
(.removeChild (.-parentNode current-style) current-style))) | |
(let [new-style (js/document.createElement "style")] | |
(set! (.-id new-style) "mystyle") | |
(.appendChild new-style (js/document.createTextNode css-text)) | |
(.appendChild (.-head js/document) new-style))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment