cursive icon indicating copy to clipboard operation
cursive copied to clipboard

No support for dom methods in ClojureScript?

Open graforlock opened this issue 7 years ago • 8 comments

Whenever I try to do any of DOM type of stuff like .getElementById I get cannot resolve. And that through a stock lein template for clojurescript. Is that the kind of support Cursive has for ClojureScript? Reloading/Invalidating etc does not help.

zrzut ekranu 2018-10-28 o 10 33 17

If this is true and expected it'd be quite disappointing for CLJS support.

So my question is: Is this a bug or this is the degree of CLJS support?

graforlock avatar Oct 28 '18 10:10 graforlock

I also have this question. I installed cursive to try it out and in a very basic hello world project it says "cannot resolve js/require". The Cursive website advertises "First class ClojureScript support" so I don't know why it seems to fail on basic builtins.

evelant avatar Feb 21 '19 01:02 evelant

Related - https://github.com/cursive-ide/cursive/issues/1211

It is possible to avoid these issues to some extent by using the underlying Google Closure library, in this case the goog.dom module. Add [goog.dom :as gdom] to :require and use (gdom/getElement "app") instead of (.getElementById js/document "app").

You can find the Google Closure API docs here.

(I recognise that it has been two years since the issue was opened, but I hope this comment serves as documentation for other folk who run into this issue)

jozuas avatar Nov 22 '20 14:11 jozuas

Hey @jozuas, I know this is an old thread, but there's something still bugging me about aliasing goog namespaces to make Cursive detect them.

For example, if I only require a namespace, such as [goog.object] like this, Cursive is not able to detect goog.object/get function... But if I use an alias, such as [goog.object :as gobject], then Cursive is able to detect the symbol and offers pertinent documentation on the method (e.g. gobject/get).

To your knowledge, is there a workaround to make it visible to Cursive with the former option?

cc @cursive-ide

joshuamzm avatar May 30 '22 23:05 joshuamzm

Hi @joshuamzm, I do not know of a workaround, I switched to Doom Emacs 😄.

jozuas avatar May 31 '22 07:05 jozuas