Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions addon/instance-initializers/clear-double-boot.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
// application will replace the pre-rendered output
export function clearHtml() {
let current = document.getElementById('fastboot-body-start');
if (current) {
let endMarker = document.getElementById('fastboot-body-end');
let endMarker = document.getElementById('fastboot-body-end');

if (current && endMarker) {
let shoeboxNodes = document.querySelectorAll('[type="fastboot/shoebox"]');
let shoeboxNodesArray = []; // Note that IE11 doesn't support more concise options like Array.from, so we have to do something like this
for(let i=0; i < shoeboxNodes.length; i++){
Expand Down
11 changes: 11 additions & 0 deletions tests/integration/instance-initializers/clear-double-boot-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,15 @@ module('Instance-initializer: clear-double-boot', function(hooks) {
assert.notOk(this.element.querySelector('#fastboot-body-end'), 'There is no end marker');
assert.notOk(this.element.querySelector('#content-in-between'), 'The content is between is gone');
})

test('It can handle missing fastboot-body-end', async function(assert) {
this.set('BAD_HTML', `<script type="x/boundary" id="fastboot-body-start"></script>`);

// render the whole tree dynamically to more closely mimc bad markup cases
await render(hbs`{{{BAD_HTML}}}`);

clearHtml();

assert.strictEqual(this.element.innerHTML, this.get('BAD_HTML'));
})
});
5 changes: 4 additions & 1 deletion vendor/experimental-render-mode-rehydrate.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
// guarded for
current.parentNode.removeChild(current);
var end = document.getElementById('fastboot-body-end');
end.parentNode.removeChild(end);

if (end) {
end.parentNode.removeChild(end);
}
}
}
})();