mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-23 19:40:56 +08:00
toJson should serialize inherited properties, but not any properties that start with $
This commit is contained in:
@@ -74,11 +74,18 @@ JsonTest.prototype.testItShouldPreventRecursion = function () {
|
||||
assertEquals('{"a":"b","recursion":RECURSION}', angular.toJson(obj));
|
||||
};
|
||||
|
||||
JsonTest.prototype.testItShouldSerializeOnlyOwnProperties = function() {
|
||||
var parent = createScope();
|
||||
var child = createScope(parent);
|
||||
child.c = 'c';
|
||||
expect(angular.toJson(child)).toEqual('{"c":"c"}');
|
||||
JsonTest.prototype.testItShouldIgnore$Properties = function() {
|
||||
var scope = createScope();
|
||||
scope.a = 'a';
|
||||
scope['$b'] = '$b';
|
||||
scope.c = 'c';
|
||||
expect(angular.toJson(scope)).toEqual('{"a":"a","c":"c","this":RECURSION}');
|
||||
};
|
||||
|
||||
JsonTest.prototype.testItShouldSerializeInheritedProperties = function() {
|
||||
var scope = createScope({p:'p'});
|
||||
scope.a = 'a';
|
||||
expect(angular.toJson(scope)).toEqual('{"a":"a","p":"p","this":RECURSION}');
|
||||
};
|
||||
|
||||
JsonTest.prototype.testItShouldSerializeSameObjectsMultipleTimes = function () {
|
||||
|
||||
Reference in New Issue
Block a user