From 5fafef81f47ea4143eac6a62a8c69b880a1f82d3 Mon Sep 17 00:00:00 2001 From: Kelly Selden Date: Tue, 16 May 2017 11:19:42 -0700 Subject: [PATCH] handle undefined in shoebox --- src/ember-app.js | 4 +++- test/fastboot-shoebox-test.js | 9 +++++++++ test/fixtures/shoebox/fastboot/fastboot-test.js | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/ember-app.js b/src/ember-app.js index 1c6d9d4..5f3cb42 100644 --- a/src/ember-app.js +++ b/src/ember-app.js @@ -450,7 +450,9 @@ function createShoebox(doc, fastbootInfo) { let value = shoebox[key]; let textValue = JSON.stringify(value); - textValue = escapeJSONString(textValue); + if (textValue !== undefined) { + textValue = escapeJSONString(textValue); + } let scriptText = doc.createRawHTMLSection(textValue); let scriptEl = doc.createElement('script'); diff --git a/test/fastboot-shoebox-test.js b/test/fastboot-shoebox-test.js index 0783844..e2809b3 100644 --- a/test/fastboot-shoebox-test.js +++ b/test/fastboot-shoebox-test.js @@ -23,6 +23,9 @@ describe("FastBootShoebox", function() { expect(html).to.include(''); expect(html).to.include(''); + + // handles undefined + expect(html).to.include(''); }); }); @@ -43,6 +46,9 @@ describe("FastBootShoebox", function() { expect(html).to.include(''); expect(html).to.include(''); + + // handles undefined + expect(html).to.include(''); }); }); @@ -63,6 +69,9 @@ describe("FastBootShoebox", function() { expect(html).to.not.include(''); expect(html).to.not.include(''); + + // handles undefined + expect(html).to.not.include(''); }); }); }); diff --git a/test/fixtures/shoebox/fastboot/fastboot-test.js b/test/fixtures/shoebox/fastboot/fastboot-test.js index d7a497e..17a02ff 100644 --- a/test/fixtures/shoebox/fastboot/fastboot-test.js +++ b/test/fixtures/shoebox/fastboot/fastboot-test.js @@ -300,6 +300,7 @@ define('fastboot-test/routes/application', ['exports', 'ember'], function (expor shoebox.put('key3', { htmlSpecialCase: 'R&B > Jazz' }); shoebox.put('key4', { nastyScriptCase: "" }); shoebox.put('key5', { otherUnicodeChars: '&&>><<\u2028\u2028\u2029\u2029' }); + shoebox.put('key6', undefined); } } });