Bladeren bron

use Function() to access global stuffs (see #4138)

Andy Li 10 jaren geleden
bovenliggende
commit
5fc4f8d42c

+ 1 - 1
std/js/html/compat/ArrayBuffer.hx

@@ -53,7 +53,7 @@ class ArrayBuffer {
 	}
 
 	static function __init__() untyped {
-		var ArrayBuffer = __js__('typeof(window) != "undefined" && window.ArrayBuffer') || __js__('typeof(global) != "undefined" && global.ArrayBuffer') || ArrayBuffer;
+		var ArrayBuffer = untyped __js__("Function(\"return typeof ArrayBuffer != 'undefined' ? ArrayBuffer : null\")()");
 		if( ArrayBuffer.prototype.slice == null ) ArrayBuffer.prototype.slice = sliceImpl; // IE10
 	}
 }

+ 1 - 1
std/js/html/compat/DataView.hx

@@ -138,7 +138,7 @@ class DataView {
 	}
 
 	static function __init__() untyped {
-		var DataView = __js__('typeof(window) != "undefined" && window.DataView') || (__js__('typeof(global) != "undefined" && global.DataView')) || DataView;
+		var DataView = untyped __js__("Function(\"return typeof DataView != 'undefined' ? DataView : null\")()");
 	}
 
 }

+ 1 - 1
std/js/html/compat/Float32Array.hx

@@ -103,7 +103,7 @@ class Float32Array {
 	}
 
 	static function __init__() untyped {
-		var Float32Array = __js__('typeof(window) != "undefined" && window.Float32Array') || (__js__('typeof(global) != "undefined" && global.Float32Array')) || _new;
+		var Float32Array = untyped __js__("Function(\"return typeof Float32Array != 'undefined' ? Float32Array : null\")()") || _new;
 	}
 
 }

+ 1 - 1
std/js/html/compat/Float64Array.hx

@@ -110,7 +110,7 @@ class Float64Array {
 	}
 
 	static function __init__() untyped {
-		var Float64Array = __js__('typeof(window) != "undefined" && window.Float64Array') || __js__('typeof(window) != "undefined" && window.Float32Array && "notsupported"') || (__js__('typeof(global) != "undefined" && global.Float64Array')) || _new;
+		var Float64Array = untyped __js__("Function(\"return typeof Float32Array != 'undefined' ? (typeof Float64Array != 'undefined' ? Float64Array : 'notsupported') : null\")()") || _new;
 	}
 
 }

+ 1 - 1
std/js/html/compat/Uint8Array.hx

@@ -94,7 +94,7 @@ class Uint8Array {
 	}
 
 	static function __init__() untyped {
-		var Uint8Array = __js__('typeof(window) != "undefined" && window.Uint8Array') || (__js__('typeof(global) != "undefined" && global.Uint8Array')) || _new;
+		var Uint8Array = untyped __js__("Function(\"return typeof Uint8Array != 'undefined' ? Uint8Array : null\")()") || _new;
 	}
 
 }