Skip to content

Commit da6432f

Browse files
committed
CLJS-3167: Warn regarding goog.dom/setTextContext with browser REPL
goog var support found typo. If info has @param, consider as fn. if no @return, assume returns nil. NOTE: still need to consider user supplied libs which may not provide this kind of type information.
1 parent afc82b1 commit da6432f

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

src/main/cljs/clojure/browser/repl.cljs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@
185185
(gobj/set "onreadystatechange" onload)) ;; IE
186186
(if (nil? opt_sourceText)
187187
(doto script (gobj/set "src" src))
188-
(doto script (gdom/setTextContext opt_sourceText))))))))
188+
(doto script (gdom/setTextContent opt_sourceText))))))))
189189
;; queue or load
190190
(set! (.-writeScriptTag_ js/goog)
191191
(fn [src opt_sourceText]

src/main/clojure/cljs/externs.clj

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,15 @@
6060
(cond-> {:tag 'Function}
6161
(.isConstructor info) (merge {:ctor qname})
6262
(.isInterface info) (merge {:iface qname})))
63-
(if (.hasReturnType info)
63+
(if (or (.hasReturnType info)
64+
(as-> (.getParameterCount info) c
65+
(and c (pos? c))))
6466
(let [arglist (into [] (map symbol (.getParameterNames info)))
6567
arglists (params->method-params arglist)]
6668
{:tag 'Function
6769
:js-fn-var true
68-
:ret-tag (get-tag (.getReturnType info))
70+
:ret-tag (or (some-> (.getReturnType info) get-tag)
71+
'clj-nil)
6972
:variadic? (boolean (some '#{var_args} arglist))
7073
:max-fixed-arity (count (take-while #(not= 'var_args %) arglist))
7174
:method-params arglists
@@ -209,16 +212,17 @@
209212
(SourceFile/fromInputStream f (io/input-stream rsrc))))})))
210213

211214
(comment
212-
213-
(pprint (analyze-goog-file "goog/object/object.js"))
214-
215-
(pprint (analyze-goog-file "goog/string/string.js"))
216-
217215
(require '[clojure.java.io :as io]
218216
'[cljs.closure :as closure]
219217
'[clojure.pprint :refer [pprint]]
220218
'[cljs.js-deps :as js-deps])
221219

220+
(pprint
221+
(get-in (analyze-goog-file "goog/dom/dom.js")
222+
[:defs 'setTextContent]))
223+
224+
(pprint (analyze-goog-file "goog/string/string.js"))
225+
222226
(get (js-deps/js-dependency-index {}) "goog.string")
223227

224228
;; {:tag Function :ret-tag boolean}

0 commit comments

Comments
 (0)