This commit is contained in:
Dan Holmsand 2016-09-16 10:00:50 +02:00
commit a5ff3b23a7
2 changed files with 10 additions and 4 deletions

View File

@ -109,7 +109,7 @@
(contains? these-inputs-have-selection-api input-type))
(defn input-set-value [this]
(when-some [node ($ this :cljsInputElement)]
(when-some [node ($ util/react-dom findDOMNode this)]
($! this :cljsInputDirty false)
(let [rendered-value ($ this :cljsRenderedValue)
dom-value ($ this :cljsDOMValue)]
@ -175,15 +175,14 @@
(let [v ($ jsprops :value)
value (if (nil? v) "" v)
on-change ($ jsprops :onChange)]
(when (nil? ($ this :cljsInputElement))
(when (nil? ($ this :cljsDOMValue))
;; set initial value
($! this :cljsDOMValue value))
($! this :cljsRenderedValue value)
(js-delete jsprops "value")
(doto jsprops
($! :defaultValue value)
($! :onChange #(input-handle-change this on-change %))
($! :ref #($! this :cljsInputElement %1))))))
($! :onChange #(input-handle-change this on-change %))))))
(defn ^boolean input-component? [x]
(case x

View File

@ -10,6 +10,13 @@
(throw (js/Error. "require('react') failed")))
:else (throw (js/Error. "js/React is missing"))))
(defonce react-dom
(cond (exists? js/ReactDOM) js/ReactDOM
(exists? js/require) (or (js/require "react-dom")
(throw (js/Error. "require('react-dom') failed")))
:else
(throw (js/Error. "js/ReactDOM is missing"))))
(def is-client (and (exists? js/window)
(-> js/window ($ :document) nil? not)))