mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-05 21:54:42 +00:00
fix(filter): make json filter ignore private properties
This commit is contained in:
parent
8ee32a75f0
commit
e134a8335f
4 changed files with 6 additions and 9 deletions
|
|
@ -126,7 +126,7 @@ function toJsonArray(buf, obj, pretty, stack) {
|
||||||
var childPretty = pretty ? pretty + " " : false;
|
var childPretty = pretty ? pretty + " " : false;
|
||||||
var keys = [];
|
var keys = [];
|
||||||
for(var k in obj) {
|
for(var k in obj) {
|
||||||
if (obj.hasOwnProperty(k) && obj[k] !== undefined) {
|
if (k!='this' && k!='$parent' && k.substring(0,2) != '$$' && obj.hasOwnProperty(k) && obj[k] !== undefined) {
|
||||||
keys.push(k);
|
keys.push(k);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -254,7 +254,6 @@ var GET_TIME_ZONE = /[A-Z]{3}(?![+\-])/,
|
||||||
OPERA_TOSTRING_PATTERN = /^[\d].*Z$/,
|
OPERA_TOSTRING_PATTERN = /^[\d].*Z$/,
|
||||||
NUMBER_STRING = /^\d+$/;
|
NUMBER_STRING = /^\d+$/;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @workInProgress
|
* @workInProgress
|
||||||
* @ngdoc filter
|
* @ngdoc filter
|
||||||
|
|
@ -409,7 +408,7 @@ angularFilter.date = function(date, format) {
|
||||||
*/
|
*/
|
||||||
angularFilter.json = function(object) {
|
angularFilter.json = function(object) {
|
||||||
this.$element.addClass("ng-monospace");
|
this.$element.addClass("ng-monospace");
|
||||||
return toJson(object, true);
|
return toJson(object, true, /^(\$|this$)/);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -514,12 +514,6 @@ describe('angular', function(){
|
||||||
expect(angular.scope().$service('svc2')).toEqual('svc2-svc1');
|
expect(angular.scope().$service('svc2')).toEqual('svc2-svc1');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should inject infered dependencies when $inject is missing', function() {
|
|
||||||
angular.service('svc1', function() { return 'svc1'; });
|
|
||||||
angular.service('svc2', function(svc1) { return 'svc2-' + svc1; });
|
|
||||||
expect(angular.scope().$service('svc2')).toEqual('svc2-svc1');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should eagerly instantiate a service if $eager is true', function() {
|
it('should eagerly instantiate a service if $eager is true', function() {
|
||||||
var log = [];
|
var log = [];
|
||||||
angular.service('svc1', function() { log.push('svc1'); }, {$eager: true});
|
angular.service('svc1', function() { log.push('svc1'); }, {$eager: true});
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,10 @@ describe('json', function(){
|
||||||
expect(toJson("a \t \n \r b \\")).toEqual('"a \\t \\n \\r b \\\\"');
|
expect(toJson("a \t \n \r b \\")).toEqual('"a \\t \\n \\r b \\\\"');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should not serialize $$properties', function(){
|
||||||
|
expect(toJson({$$some:'value', 'this':1, '$parent':1}, false)).toEqual('{}');
|
||||||
|
});
|
||||||
|
|
||||||
it('should serialize strings with escaped characters', function() {
|
it('should serialize strings with escaped characters', function() {
|
||||||
expect(toJson("7\\\"7")).toEqual("\"7\\\\\\\"7\"");
|
expect(toJson("7\\\"7")).toEqual("\"7\\\\\\\"7\"");
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue