Added undefined guards to uses of JSON stringify/parse copying

no issue
- added guards for JSON stringify+parse replacements of `Ember.copy` introduced in 6fe40b941b
This commit is contained in:
Kevin Ansfield 2019-01-30 14:44:53 +00:00
parent 6fe40b941b
commit b7e0614362
3 changed files with 3 additions and 3 deletions

View File

@ -318,7 +318,7 @@ export default Controller.extend({
// set mobiledoc equal to what's in the editor but create a copy so that
// nested objects/arrays don't keep references which can mean that both
// scratch and mobiledoc get updated simultaneously
this.set('post.mobiledoc', JSON.parse(JSON.stringify(this.post.scratch)));
this.set('post.mobiledoc', JSON.parse(JSON.stringify(this.post.scratch || null)));
this.set('post.status', status);
// Set a default title

View File

@ -312,7 +312,7 @@ export default Component.extend({
// `payload.files` is special because it's set by paste/drag-n-drop
// events and can't be copied for security reasons
let {files} = payload;
let payloadCopy = JSON.parse(JSON.stringify(payload));
let payloadCopy = JSON.parse(JSON.stringify(payload || null));
payloadCopy.files = files;
// all of the properties that will be passed through to the

View File

@ -163,7 +163,7 @@ export default Component.extend({
}).compact();
// we need a copy to avoid modifying the object references
let sections = JSON.parse(JSON.stringify(matchedItems));
let sections = JSON.parse(JSON.stringify(matchedItems || []));
if (sections.length) {
set(sections[0].items[0], 'selected', true);