Skip to content

Commit 13f96e7

Browse files
author
Robert Jackson
authored
Terrible, Awful, No Good, Very Bad Markup Crashes App (#699)
Terrible, Awful, No Good, Very Bad Markup Crashes App
2 parents e6d8f06 + c0ec985 commit 13f96e7

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

addon/instance-initializers/clear-double-boot.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export function clearHtml() {
2222
parent.removeChild(current);
2323
current = nextNode;
2424
} while (nextNode && nextNode !== endMarker && shoeboxNodesArray.indexOf(nextNode) < 0);
25-
parent.removeChild(endMarker);
25+
endMarker.parentElement.removeChild(endMarker);
2626
}
2727
}
2828
export default {

tests/integration/instance-initializers/clear-double-boot-test.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,22 @@ module('Instance-initializer: clear-double-boot', function(hooks) {
1818
assert.notOk(this.element.querySelector('#fastboot-body-end'), 'There is no end marker');
1919
assert.notOk(this.element.querySelector('#content-in-between'), 'The content is between is gone');
2020
});
21+
22+
test('It can handle bad markup', async function(assert) {
23+
this.set('BAD_HTML', `
24+
<script type="x/boundary" id="fastboot-body-start"></script>
25+
<div id="content-in-between">
26+
<em><em>
27+
</div>
28+
<script type="x/boundary" id="fastboot-body-end"></script>
29+
`);
30+
31+
// render the whole tree dynamically to more closely mimc bad markup cases
32+
await render(hbs`{{{BAD_HTML}}}`);
33+
34+
clearHtml();
35+
assert.notOk(this.element.querySelector('#fastboot-body-start'), 'There is no start marker');
36+
assert.notOk(this.element.querySelector('#fastboot-body-end'), 'There is no end marker');
37+
assert.notOk(this.element.querySelector('#content-in-between'), 'The content is between is gone');
38+
})
2139
});

0 commit comments

Comments
 (0)