ClojureScript

Remove use of js* from demo app code

Details

  • Type: Enhancement Enhancement
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None

Description

Twitterbuzz uses js* in several places to access objects in the browser, like Math and Regexp. js* shouldn't be used like this. Use goog.global.Math form instead.

goog.global works because gclosure compiler is loaded with dom/browser externs, and knows about these objects. They just need to be referred to the right way.

Activity

Hide
Alan Dipert added a comment -

goog.global.Math and goog.global.RegExp are provided by gclosure's default externs. They can be accessed with goog.global.x, where x is a global object in an extern'd environment.

RegExp, for reasons unknown, cannot be reliably accessed this way from cljs source. As a result, re-pattern in core is implemented on top of js*. For the possibly wrong but working solution, see https://github.com/clojure/clojurescript/blob/329fb01483452288c158195c94c95f94d9bd5cfd/src/cljs/cljs/core.cljs#L2375

Show
Alan Dipert added a comment - goog.global.Math and goog.global.RegExp are provided by gclosure's default externs. They can be accessed with goog.global.x, where x is a global object in an extern'd environment. RegExp, for reasons unknown, cannot be reliably accessed this way from cljs source. As a result, re-pattern in core is implemented on top of js*. For the possibly wrong but working solution, see https://github.com/clojure/clojurescript/blob/329fb01483452288c158195c94c95f94d9bd5cfd/src/cljs/cljs/core.cljs#L2375

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: