Parcourir la source

remove haxe.Json implementation in JS unless -D oldBrowser is specified (close #2227)

Nicolas Cannasse il y a 12 ans
Parent
commit
f2ae588924
2 fichiers modifiés avec 4 ajouts et 3 suppressions
  1. 1 0
      doc/CHANGES.txt
  2. 3 3
      std/haxe/Json.hx

+ 1 - 0
doc/CHANGES.txt

@@ -18,6 +18,7 @@
 	js : window and console are reserved words. Access them with __js__ instead of untyped.
 	js : added -D js-flatten
 	js : improved inlining
+	js : always use JSON extern (compile with -D oldBrowser to disable)
 	cpp : improved side-effect detection
 	macro : allowed $v{(c:Float|Int|String)}
 	macro : resolve error line number in external files

+ 3 - 3
std/haxe/Json.hx

@@ -26,12 +26,12 @@ package haxe;
 	Use -D haxeJSON to force usage of the Haxe implementation even if a native API is found : this will provide
 	extra encoding features such as enums (replaced by their index), Hashs and Iterable.
 **/
-#if (flash11 && !haxeJSON)
+#if ((flash11 || (js && !oldBrowser)) && !haxeJSON)
 @:native('JSON') extern
 #end
 class Json {
 
-#if (haxeJSON || !flash11)
+#if (haxeJSON || !(flash11 || (js && !oldBrowser)))
 	var buf : #if flash9 flash.utils.ByteArray #else StringBuf #end;
 	var str : String;
 	var pos : Int;
@@ -416,7 +416,7 @@ class Json {
 	}
 
 	#if !haxeJSON
-		#if js
+		#if (js && oldBrowser)
 		static function __init__() untyped {
 			if( __js__('typeof(JSON)') != 'undefined' )
 				Json = __js__('JSON');