diff options
| author | Igor Minar | 2012-03-27 12:44:37 -0700 |
|---|---|---|
| committer | Igor Minar | 2012-03-28 16:57:22 -0700 |
| commit | 35125d25137ac2da13ed1ca3e652ec8f2c945053 (patch) | |
| tree | 387623dfc398e04c17ea15917d2d8e8cbf40bf19 /src/ng | |
| parent | 87f5c6e5b716100e203ec59c5874c3e927f83fa0 (diff) | |
| download | angular.js-35125d25137ac2da13ed1ca3e652ec8f2c945053.tar.bz2 | |
refactor(toJson): use native JSON.stringify
Instead of using our custom serializer we now use the native one and
use the replacer function to customize the serialization to preserve
most of the previous behavior (ignore $ and $$ properties as well
as window, document and scope instances).
Diffstat (limited to 'src/ng')
| -rw-r--r-- | src/ng/directive/input.js | 4 | ||||
| -rw-r--r-- | src/ng/filter/filters.js | 2 | ||||
| -rw-r--r-- | src/ng/filter/limitTo.js | 10 |
3 files changed, 8 insertions, 8 deletions
diff --git a/src/ng/directive/input.js b/src/ng/directive/input.js index 348c9f25..7343c358 100644 --- a/src/ng/directive/input.js +++ b/src/ng/directive/input.js @@ -671,7 +671,7 @@ function checkboxInputType(scope, element, attr, ctrl) { </doc:source> <doc:scenario> it('should initialize to model', function() { - expect(binding('user')).toEqual('{"last":"visitor","name":"guest"}'); + expect(binding('user')).toEqual('{"name":"guest","last":"visitor"}'); expect(binding('myForm.userName.$valid')).toEqual('true'); expect(binding('myForm.$valid')).toEqual('true'); }); @@ -685,7 +685,7 @@ function checkboxInputType(scope, element, attr, ctrl) { it('should be valid if empty when min length is set', function() { input('user.last').enter(''); - expect(binding('user')).toEqual('{"last":"","name":"guest"}'); + expect(binding('user')).toEqual('{"name":"guest","last":""}'); expect(binding('myForm.lastName.$valid')).toEqual('true'); expect(binding('myForm.$valid')).toEqual('true'); }); diff --git a/src/ng/filter/filters.js b/src/ng/filter/filters.js index c792cace..19f79ad1 100644 --- a/src/ng/filter/filters.js +++ b/src/ng/filter/filters.js @@ -407,7 +407,7 @@ function dateFilter($locale) { </doc:source> <doc:scenario> it('should jsonify filtered objects', function() { - expect(binding("{'name':'value'}")).toBe('{\n "name":"value"}'); + expect(binding("{'name':'value'}")).toMatch(/\{\n "name": ?"value"\n}/); }); </doc:scenario> </doc:example> diff --git a/src/ng/filter/limitTo.js b/src/ng/filter/limitTo.js index 4928fb9a..af94b2f4 100644 --- a/src/ng/filter/limitTo.js +++ b/src/ng/filter/limitTo.js @@ -31,24 +31,24 @@ } </script> <div ng-controller="Ctrl"> - Limit {{numbers}} to: <input type="integer" ng-model="limit"/> - <p>Output: {{ numbers | limitTo:limit | json }}</p> + Limit {{numbers}} to: <input type="integer" ng-model="limit" ng-model-instant> + <p>Output: {{ numbers | limitTo:limit }}</p> </div> </doc:source> <doc:scenario> it('should limit the numer array to first three items', function() { expect(element('.doc-example-live input[ng-model=limit]').val()).toBe('3'); - expect(binding('numbers | limitTo:limit | json')).toEqual('[1,2,3]'); + expect(binding('numbers | limitTo:limit')).toEqual('[1,2,3]'); }); it('should update the output when -3 is entered', function() { input('limit').enter(-3); - expect(binding('numbers | limitTo:limit | json')).toEqual('[7,8,9]'); + expect(binding('numbers | limitTo:limit')).toEqual('[7,8,9]'); }); it('should not exceed the maximum size of input array', function() { input('limit').enter(100); - expect(binding('numbers | limitTo:limit | json')).toEqual('[1,2,3,4,5,6,7,8,9]'); + expect(binding('numbers | limitTo:limit')).toEqual('[1,2,3,4,5,6,7,8,9]'); }); </doc:scenario> </doc:example> |
