Browse files

Export JSON from json package.

Make sure to use the built-in JSON if it exists.

Fixes #1204.
  • Loading branch information...
1 parent af5efd2 commit e712d78cfb5984a29a22d56279ceffdfa17d7982 @glasser glasser committed Aug 2, 2013
Showing with 7 additions and 2 deletions.
  1. +3 −0 packages/json/json_native.js
  2. +4 −2 packages/json/package.js
View
3 packages/json/json_native.js
@@ -0,0 +1,3 @@
+// Do we already have a global JSON object? Export it as our JSON object.
+if (window.JSON)
+ JSON = window.JSON;
View
6 packages/json/package.js
@@ -3,10 +3,12 @@ Package.describe({
internal: true
});
-// We need to figure out how to serve this file only to browsers that
-// don't have JSON.stringify (eg, IE7 and earlier -- or is that IE8?)
+// We need to figure out how to serve this file only to browsers that don't have
+// JSON.stringify (eg, IE7 and earlier, and IE8 outside of "standards mode")
Package.on_use(function (api) {
// Node always has JSON; we only need this in some browsers.
+ api.export('JSON', 'client');
+ api.add_files('json_native.js', 'client');
api.add_files('json2.js', 'client');
});

0 comments on commit e712d78

Please sign in to comment.