Răsfoiți Sursa

Cope if running in a non-browser environment and these vars don't exist.

In lieu of factoring all browser bits out of js.Lib, this gets things working in environments like
nodeJS without users having to patch the standard library.
Bruno Garcia 13 ani în urmă
părinte
comite
2c5947b2cb
1 a modificat fișierele cu 4 adăugiri și 2 ștergeri
  1. 4 2
      std/js/Lib.hx

+ 4 - 2
std/js/Lib.hx

@@ -47,8 +47,10 @@ class Lib {
 	}
 
 	static function __init__() untyped {
-		document = untyped __js__("document");
-		window = untyped __js__("window");
+		if( __js__("typeof document") != "undefined" )
+			document = __js__("document");
+		if( __js__("typeof window") != "undefined" )
+			window = __js__("window");
 		#if debug
 __js__('onerror = function(msg,url,line) {
 		var stack = $s.copy();