Fix problem with custom HTML element property name code

Custom HTML element property name code accidentally modified cache
object for normal HTML elements, which can cause Reagent to lose correct
mappings for properties like className, htmlFor and charSet.
This commit is contained in:
Juho Teperi 2018-04-27 23:17:25 +03:00
parent fe2f82d032
commit 4a8ac5cd83
3 changed files with 24 additions and 4 deletions

View File

@ -82,7 +82,7 @@
(if (named? k)
(if-some [k' (cache-get custom-prop-name-cache (name k))]
k'
(aset prop-name-cache (name k)
(aset custom-prop-name-cache (name k)
(util/dash-to-camel k)))
k))

View File

@ -0,0 +1,20 @@
(ns reagent.impl.template-test
(:require [clojure.test :as t :refer [deftest is testing]]
[reagent.impl.template :as tmpl]
[goog.object :as gobj]))
(deftest cached-prop-name
(is (= "className"
(tmpl/cached-prop-name :class))))
(deftest cached-custom-prop-name
(is (= "class"
(tmpl/cached-custom-prop-name :class))))
(deftest convert-props-test
(is (gobj/equals #js {:className "a"}
(tmpl/convert-props {:class "a"} #js {:id nil :custom false})))
(is (gobj/equals #js {:class "a"}
(tmpl/convert-props {:class "a"} #js {:id nil :custom true})))
(is (gobj/equals #js {:className "a b" :id "a"}
(tmpl/convert-props {:class "b"} #js {:id "a" :class "a" :custom false}))))

View File

@ -7,6 +7,7 @@
[reagenttest.testtrack]
[reagenttest.testwithlet]
[reagenttest.testwrap]
[reagent.impl.template-test]
[cljs.test :as test]
[doo.runner :as doo :include-macros true]
[reagent.core :as r]
@ -21,8 +22,7 @@
:color :#aaa})
(defn all-tests []
#_(test/run-tests 'reagenttest.testratomasync)
(test/run-all-tests #"reagenttest.test.*"))
(test/run-all-tests #"(reagenttest\.test.*|reagent\..*-test)"))
(defmethod test/report [::test/default :summary] [m]
;; ClojureScript 2814 doesn't return anything from run-tests
@ -56,4 +56,4 @@
(run-tests)
[#'test-output-mini]))
(doo/doo-all-tests #"reagenttest.test.*")
(doo/doo-all-tests #"(reagenttest\.test.*|reagent\..*-test)")