Ver Fonte

[js] Browser.supported: Check window.document.body (#9164)

* [js] Check for existence of window.document.body as proxy for testing a browser environment

* Browser.supported = () -> window.location.protocol === 'string'

* Remove inline from get_supported

* Remove extern
George Corney há 5 anos atrás
pai
commit
9a75d9d2e2
1 ficheiros alterados com 5 adições e 3 exclusões
  1. 5 3
      std/js/Browser.hx

+ 5 - 3
std/js/Browser.hx

@@ -71,9 +71,11 @@ class Browser {
 	 */
 	public static var supported(get, never):Bool;
 
-	extern inline static function get_supported()
-		return js.Syntax.typeof(window) != "undefined";
-
+	static function get_supported()
+		return 
+			js.Syntax.typeof(window) != "undefined" &&
+			js.Syntax.typeof(window.location) != "undefined" &&
+			js.Syntax.typeof(window.location.protocol) == "string";
 	/**
 	 * Safely gets the browser's local storage, or returns null if localStorage is unsupported or
 	 * disabled.