From 04e86065e316682aca74af487a7ac2cb7cb2c455 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Mon, 2 Oct 2017 10:29:24 +0300 Subject: [PATCH 1/2] fix: snapshot failing on constructor prop --- lib/utils/helpers.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/utils/helpers.ts b/lib/utils/helpers.ts index 1ab9ab76..44f8e4df 100644 --- a/lib/utils/helpers.ts +++ b/lib/utils/helpers.ts @@ -118,12 +118,17 @@ export const isSafari = Object.prototype.toString.call(window.HTMLElement).index || (function (p) { return p.toString() === '[object SafariRemoteNotification]'; })(!window['safari'] || safari.pushNotification); +// works only for plain objects (JSON) export function snapshot(obj) { if(obj == undefined || typeof(obj) !== 'object') { return obj; } - var temp = new obj.constructor(); + if(obj instanceof Date) { + return new Date(obj.getTime()); + } + + var temp = Array.isArray(obj) ? [] : {}; for(var key in obj) { if (obj.hasOwnProperty(key)) { From af81c33c99bbead699ac1cda024ee0773fbd08e2 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Mon, 2 Oct 2017 10:52:19 +0300 Subject: [PATCH 2/2] v1.19.1 --- CHANGELOG.md | 9 +++++++++ package.json | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 25b3c827..4da43598 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ + +# [1.19.1](https://github.com/Rebilly/ReDoc/compare/v1.19.0...v1.19.1) (2017-10-02) + + +### Bug Fixes + +* snapshot crashing on `constructor` prop ([04e8606](https://github.com/Rebilly/ReDoc/commit/04e8606)), closes [#341](https://github.com/Rebilly/ReDoc/issues/341) + + # [1.19.0](https://github.com/Rebilly/ReDoc/compare/v1.18.1...v1.19.0) (2017-09-21) diff --git a/package.json b/package.json index b4cf0485..10f0d117 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "redoc", "description": "Swagger-generated API Reference Documentation", - "version": "1.19.0", + "version": "1.19.1", "repository": { "type": "git", "url": "git://github.com/Rebilly/ReDoc"