Skip to content

Commit f61ab1b

Browse files
authored
Merge pull request ember-fastboot#194 from dnalagatla/dnalagatla/update_body_in_domContents
Moved the script tag fastboot-body-start boundary in _finalizeHTML method
2 parents e8e570d + 3a5042d commit f61ab1b

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

src/result.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,9 @@ class Result {
171171
body = HTMLSerializer.serializeChildren(body);
172172

173173
this._head = head;
174-
this._body = body;
174+
175+
// Adding script boundary around the body
176+
this._body = `<script type="x/boundary" id="fastboot-body-start"></script>${body}<script type="x/boundary" id="fastboot-body-end"></script>`;
175177
}
176178
}
177179

@@ -190,7 +192,7 @@ function insertIntoIndexHTML(html, htmlAttributes, head, body, bodyAttributes) {
190192
return head;
191193
} else if (tag === 'BODY' && body && !isBodyReplaced) {
192194
isBodyReplaced = true;
193-
return '<script type="x/boundary" id="fastboot-body-start"></script>' + body + '<script type="x/boundary" id="fastboot-body-end"></script>';
195+
return body;
194196
}
195197
return '';
196198
});

test/result-test.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,4 +215,27 @@ describe('Result', function() {
215215
});
216216
});
217217
});
218+
219+
describe('domContents()', function() {
220+
var HEAD = '<meta name="foo" content="bar">';
221+
var BODY = '<h1>A normal response document</h1>';
222+
var boundaryStartTag = '<script type="x/boundary" id="fastboot-body-start"></script>';
223+
var boundaryEndTag = '<script type="x/boundary" id="fastboot-body-end"></script>';
224+
225+
beforeEach(function () {
226+
doc.head.appendChild(doc.createRawHTMLSection(HEAD));
227+
doc.body.appendChild(doc.createRawHTMLSection(BODY));
228+
229+
result._finalize();
230+
});
231+
232+
it('should return the FastBoot-rendered document body', function () {
233+
var domContents = result.domContents();
234+
expect(domContents.head).to.include(HEAD);
235+
expect(domContents.body).to.include(BODY);
236+
expect(domContents.body).to.include(boundaryStartTag);
237+
expect(domContents.body).to.include(boundaryEndTag);
238+
expect(domContents.body).to.equal(boundaryStartTag+BODY+boundaryEndTag);
239+
});
240+
});
218241
});

0 commit comments

Comments
 (0)