From b9e25fd0910e92dfda3978d66f4dcc9fbcc7d16d Mon Sep 17 00:00:00 2001 From: kwypchlo <kwypchlo@gmail.com> Date: Mon, 17 Nov 2014 21:40:37 +0100 Subject: [PATCH] fix(toDebugString): change replacement string As discussed in #10085, the original replacement string can be treated as html when displayed by the browser so it replaces it with '...' string. --- src/stringify.js | 2 +- test/minErrSpec.js | 2 +- test/stringifySpec.js | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/stringify.js b/src/stringify.js index 2c1a343c3701..86c4f881dfb9 100644 --- a/src/stringify.js +++ b/src/stringify.js @@ -9,7 +9,7 @@ function serializeObject(obj) { val = toJsonReplacer(key, val); if (isObject(val)) { - if (seen.indexOf(val) >= 0) return '<<already seen>>'; + if (seen.indexOf(val) >= 0) return '...'; seen.push(val); } diff --git a/test/minErrSpec.js b/test/minErrSpec.js index 848188c98ab0..bf1af6d60eea 100644 --- a/test/minErrSpec.js +++ b/test/minErrSpec.js @@ -65,7 +65,7 @@ describe('minErr', function() { a.b.a = a; var myError = testError('26', 'a is {0}', a); - expect(myError.message).toMatch(/a is {"b":{"a":"<<already seen>>"}}/); + expect(myError.message).toMatch(/a is {"b":{"a":"..."}}/); }); it('should preserve interpolation markers when fewer arguments than needed are provided', function() { diff --git a/test/stringifySpec.js b/test/stringifySpec.js index e849b3e86cb8..d971acf7737b 100644 --- a/test/stringifySpec.js +++ b/test/stringifySpec.js @@ -9,7 +9,7 @@ describe('toDebugString', function() { expect(toDebugString()).toEqual('undefined'); var a = { }; a.a = a; - expect(toDebugString(a)).toEqual('{"a":"<<already seen>>"}'); - expect(toDebugString([a,a])).toEqual('[{"a":"<<already seen>>"},"<<already seen>>"]'); + expect(toDebugString(a)).toEqual('{"a":"..."}'); + expect(toDebugString([a,a])).toEqual('[{"a":"..."},"..."]'); }); });