From 9a4aa1cae507d7cff423a16752976ab2676e5607 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 | 2 ++ test/fastboot-shoebox-test.js | 9 +++++++++ test/fixtures/shoebox/fastboot/fastboot-test.js | 1 + 3 files changed, 12 insertions(+) diff --git a/src/ember-app.js b/src/ember-app.js index ea5c636..0ec4327 100644 --- a/src/ember-app.js +++ b/src/ember-app.js @@ -422,6 +422,8 @@ function createShoebox(doc, fastbootInfo) { let value = shoebox[key]; let textValue = JSON.stringify(value); + if (textValue === undefined) { continue; } + textValue = escapeJSONString(textValue); let scriptText = doc.createRawHTMLSection(textValue); diff --git a/test/fastboot-shoebox-test.js b/test/fastboot-shoebox-test.js index 0783844..c7e26cb 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(''); + + // ignores undefined + expect(html).to.not.include('shoebox-key6'); }); }); @@ -43,6 +46,9 @@ describe("FastBootShoebox", function() { expect(html).to.include(''); expect(html).to.include(''); + + // ignores undefined + expect(html).to.not.include('shoebox-key6'); }); }); @@ -63,6 +69,9 @@ describe("FastBootShoebox", function() { expect(html).to.not.include(''); expect(html).to.not.include(''); + + // ignores undefined + expect(html).to.not.include('shoebox-key6'); }); }); }); 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); } } });