Bläddra i källkod

[js] patch slice anyway

Andy Li 10 år sedan
förälder
incheckning
19b23c5260
1 ändrade filer med 6 tillägg och 7 borttagningar
  1. 6 7
      std/js/_std/Array.hx

+ 6 - 7
std/js/_std/Array.hx

@@ -44,10 +44,15 @@ extern class Array<T> {
 		return @:privateAccess HxOverrides.remove(this,x);
 	}
 
+	// In case `?end` is `null` (not just `undefined`)
+	// see https://github.com/HaxeFoundation/haxe/issues/4460#issuecomment-128156336
+	inline function slice( pos : Int, ?end : Int ) : Array<T> {
+		return (untyped this).slice(pos,(end!=null)?end:length);
+	}
+
 #if js_es5
 	function indexOf( x : T, ?fromIndex:Int ) : Int;
 	function lastIndexOf( x : T, ?fromIndex:Int ) : Int;
-	function slice( pos : Int, ?end : Int ) : Array<T>;
 #else
 	inline function indexOf( x : T, ?fromIndex:Int ) : Int {
 		return @:privateAccess HxOverrides.indexOf(this,x,(fromIndex!=null)?fromIndex:0);
@@ -56,12 +61,6 @@ extern class Array<T> {
 	inline function lastIndexOf( x : T, ?fromIndex:Int ) : Int {
 		return @:privateAccess HxOverrides.lastIndexOf(this,x,(fromIndex!=null)?fromIndex:length-1);
 	}
-
-	// for IE8
-	// see https://github.com/HaxeFoundation/haxe/issues/4460#issuecomment-128156336
-	inline function slice( pos : Int, ?end : Int ) : Array<T> {
-		return (untyped this).slice(pos,(end!=null)?end:length);
-	}
 #end
 
 	inline function copy() : Array<T> {