2
0
Эх сурвалжийг харах

Fix all usages of untyped window.

...In the standard library at least. We're probably going to see some
third party library breakage when #2139 goes out. No pain, no gain I
guess?
Bruno Garcia 12 жил өмнө
parent
commit
0d1cc44dbb

+ 3 - 3
std/haxe/remoting/ExternalConnection.hx

@@ -67,8 +67,8 @@ class ExternalConnection implements Connection implements Dynamic<Connection> {
 		#if flash
 			data = flash.external.ExternalInterface.call("haxe.remoting.ExternalConnection.doCall",__data.name,__path.join("."),params);
 		#elseif js
-			var fobj : Dynamic = untyped window.document[__data.flash];
-			if( fobj == null ) fobj = untyped window.document.getElementById(__data.flash);
+			var fobj : Dynamic = (untyped js.Browser.document)[__data.flash]; // FIXME(bruno): Why is this necessary?
+			if( fobj == null ) fobj = js.Browser.document.getElementById(__data.flash);
 			if( fobj == null ) throw "Could not find flash object '"+__data.flash+"'";
 			try	data = fobj.externalRemotingCall(__data.name,__path.join("."),params) catch( e : Dynamic ) {};
 		#end
@@ -78,7 +78,7 @@ class ExternalConnection implements Connection implements Dynamic<Connection> {
 			try {
 				// check that swf in on the same domain
 				domain = fobj.src.split("/")[2];
-				pageDomain = js.Browser.window.location.host;
+				pageDomain = js.Browser.location.host;
 			} catch( e : Dynamic ) {
 				domain = null;
 				pageDomain = null;

+ 2 - 2
std/haxe/remoting/FlashJsConnection.hx

@@ -141,8 +141,8 @@ class FlashJsConnection #if flash implements AsyncConnection implements Dynamic<
 
 	static function flashCall( flashObj : String, name : String, path : String, params : String ) : String {
 		try {
-			var fobj : Dynamic = untyped window.document[flashObj];
-			if( fobj == null ) fobj = untyped window.document.getElementById(flashObj);
+			var fobj : Dynamic = (untyped js.Browser.document)[__data.flash]; // FIXME(bruno): Why is this necessary?
+			if( fobj == null ) fobj = js.Browser.document.getElementById(flashObj);
 			if( fobj == null ) throw "Could not find flash object '"+flashObj+"'";
 			var data = null;
 			try data = fobj.flashJsRemotingCall(name,path,params) catch( e : Dynamic ) {};

+ 4 - 4
std/haxe/web/Request.hx

@@ -32,7 +32,7 @@ class Request {
 		#elseif php
 		return php.Web.getParams();
 		#elseif js
-		var get : String = untyped window.location.search.substr(1);
+		var get : String = js.Browser.location.search.substr(1);
 		var params = new haxe.ds.StringMap();
 		for( p in ~/[&;]/g.split(get) ) {
 			var pl = p.split("=");
@@ -53,7 +53,7 @@ class Request {
 		#elseif php
 		return php.Web.getHostName();
 		#elseif js
-		return untyped window.location.host; // includes port
+		return js.Browser.location.host; // includes port
 		#end
 	}
 
@@ -66,8 +66,8 @@ class Request {
 		#elseif php
 		return php.Web.getURI();
 		#elseif js
-		return untyped window.location.pathname;
+		return js.Browser.location.pathname;
 		#end
 	}
 
-}
+}

+ 1 - 1
std/js/JQuery.hx

@@ -398,7 +398,7 @@ extern class JQuery implements ArrayAccess<Element> {
 		if( untyped __js__("typeof($) == 'undefined'") )
 			haxe.macro.Compiler.includeFile("js/jquery-latest.min.js");
 		#end
-		var q : Dynamic = __js__("window").jQuery;
+		var q : Dynamic = (untyped js.Browser.window).jQuery;
 		js.JQuery = q;
 		__feature__('js.JQuery.iterator',
 			q.fn.iterator = function() return { pos : 0, j : __this__, hasNext : function() return __this__.pos < __this__.j.length, next : function() return $(__this__.j[__this__.pos++]) }

+ 8 - 6
std/js/Scroll.hx

@@ -21,11 +21,13 @@
  */
 package js;
 
+import js.Browser.*;
+
 class Scroll {
 
-	public static function getTop() : Int untyped {
+	public static function getTop() : Int {
 		var sy = window.pageYOffset;
-		if( __js__("typeof")(sy) == 'number' )
+		if( untyped __js__("typeof")(sy) == 'number' )
 			return sy;
 		if( document.body ) {
 			sy = document.body.scrollTop;
@@ -34,9 +36,9 @@ class Scroll {
 		return document.documentElement.scrollTop;
 	}
 
-	public static function getLeft() : Int untyped {
+	public static function getLeft() : Int {
 		var sx = window.pageXOffset;
-		if( __js__("typeof")(sx) == 'number' )
+		if( untyped __js__("typeof")(sx) == 'number' )
 			return sx;
 		if( document.body ) {
 			sx = document.body.scrollLeft;
@@ -45,8 +47,8 @@ class Scroll {
 		return document.documentElement.scrollLeft;
 	}
 
-	public static function set(left:Int,top:Int) untyped {
+	inline public static function set(left:Int,top:Int) {
 		window.scroll(left,top);
 	}
 
-}
+}