From 5a294c8646452d6e49339d145faeae4f31dcd0fc Mon Sep 17 00:00:00 2001 From: Greg Thornton Date: Sun, 23 Jun 2013 14:04:59 -0500 Subject: feat(Angular.js): skip JSON.stringify for undefined Return early in `angular.toJson` if the object to be stringified is `undefined`. IE8 stringifies `undefined` to `'undefined'` whereas other browsers return `undefined`. This normalizes behavior and passes currently broken unit tests in IE8. --- test/AngularSpec.js | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'test/AngularSpec.js') diff --git a/test/AngularSpec.js b/test/AngularSpec.js index bf952249..da70aef7 100644 --- a/test/AngularSpec.js +++ b/test/AngularSpec.js @@ -909,6 +909,10 @@ describe('angular', function() { it('should not serialize scope instances', inject(function($rootScope) { expect(toJson({key: $rootScope})).toEqual('{"key":"$SCOPE"}'); })); + + it('should serialize undefined as undefined', function() { + expect(toJson(undefined)).toEqual(undefined); + }); }); }); -- cgit v1.2.3