Skip to content

Commit

Permalink
Terrible, Awful, No Good, Very Bad Markup Crashes App (#699)
Browse files Browse the repository at this point in the history
Terrible, Awful, No Good, Very Bad Markup Crashes App
  • Loading branch information
rwjblue committed Jun 3, 2019
2 parents e6d8f06 + c0ec985 commit 13f96e7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion addon/instance-initializers/clear-double-boot.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function clearHtml() {
parent.removeChild(current);
current = nextNode;
} while (nextNode && nextNode !== endMarker && shoeboxNodesArray.indexOf(nextNode) < 0);
parent.removeChild(endMarker);
endMarker.parentElement.removeChild(endMarker);
}
}
export default {
Expand Down
18 changes: 18 additions & 0 deletions tests/integration/instance-initializers/clear-double-boot-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,22 @@ 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 bad markup', async function(assert) {
this.set('BAD_HTML', `
<script type="x/boundary" id="fastboot-body-start"></script>
<div id="content-in-between">
<em><em>
</div>
<script type="x/boundary" id="fastboot-body-end"></script>
`);

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

clearHtml();
assert.notOk(this.element.querySelector('#fastboot-body-start'), 'There is no start marker');
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');
})
});

0 comments on commit 13f96e7

Please sign in to comment.