File tree Expand file tree Collapse file tree
main/clojure/clojure/data/xml/js
test/clojurescript/clojure/data/xml Expand file tree Collapse file tree Original file line number Diff line number Diff line change 7979(def NamedNodeMap (type (.-attributes (element :e ))))
8080(def NodeList (type (node-list [])))
8181(def Attr (type (aget (.-attributes (element :e {:a " 1" })) 0 )))
82+ (def CData (type (cdata " " )))
83+ (def Comment (type (xml-comment " " )))
8284
8385; ; ## Coercions
8486
8991 [el]
9092 (cond
9193 (string? el) (text-node el)
94+ (instance? node/CData el) (cdata (:content el))
95+ (instance? node/Comment el) (xml-comment (:content el))
9296 (instance? Element el) el
97+ (instance? CData el) el
98+ (instance? Comment el) el
9399 ; ; stupid xmldom, (some? (.-item el))
94100 #_(instance? NodeList el)
95101 (some? (.-item el)) el
141147 " Coerce xml elements to element maps / content vectors"
142148 [el]
143149 (cond
150+ (instance? Comment el)
151+ (node/xml-comment (.-data el))
152+ (instance? CData el)
153+ (node/cdata (.-data el))
144154 (instance? Text el)
145155 (.-nodeValue el)
146156 (instance? Element el)
Original file line number Diff line number Diff line change 1818 (are [dxml xml] (do (is (= dxml (xml/parse-str xml)))
1919 (is (= dxml (xml/parse-str (xml/emit-str dxml)))))
2020 (xml/element :foo ) " <foo/>"
21- (xml/element :xmlns.DAV%3 A/foo) " <foo xmlns=\" DAV:\" />" ))
21+ (xml/element :xmlns.DAV%3 A/foo) " <foo xmlns=\" DAV:\" />"
22+ (xml/element :foo {} (xml/cdata " <foo" )) " <foo><![CDATA[<foo]]></foo>"
23+ (xml/element :foo {} (xml/xml-comment " bar> " )) " <foo><!-- bar> --></foo>" ))
2224
2325(deftest printing
2426 (are [node ps] (is (= ps (pr-str node)))
You can’t perform that action at this time.
0 commit comments