Great, hope it gets included soon!
There are other variables that could also change like the js.Browser
For example js.Browser.document includes code to check if window.document is undefined and makes it null if so.
I dont see in JS anyone checking if document exists or not.
If i am targeting JS and using a class called Browser its because my code is to run in a browser and that variable will exist.
Again its generating unneded code and makes it more hard to read.
I usualy have my own Browser class with this:
class Browser {
public static var window(get,null) :js.html.DOMWindow;
static inline function get_window():js.html.DOMWindow return untyped __js__("window");
public static var document(get,null) :js.html.Document;
static inline function get_document():js.html.Document return untyped __js__("document");
public static var location(get,null) :js.html.Location;
static inline function get_location():js.html.Location return untyped __js__("location");
public static var navigator(get,null) :js.html.Navigator;
static inline function get_navigator():js.html.Navigator return untyped __js__("navigator");
public static var console(get, null):js.html.Console;
static inline function get_console():js.html.Console return untyped __js__("console");
public static var performance(get, null):js.html.Performance;
static inline function get_performance():js.html.Performance return untyped __js__("performance");
}
With this code using Browser.document simply generates document. It makes the code smaller and looks more like plain JS!
I am aware that (Browser.document==null) will always be false. But i dont really see people checking existance of that variable anyway.
Might be wrong...
Segunda-feira, 6 de Maio de 2013 19:56:29 UTC+1, Bruno Garcia escreveu: