Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

Commit 6be6e29

Browse files
haslam22petetnt
authored andcommitted
Fix for #12997: Live preview breaks on reload w/out editor (#13017)
* Use _masterEditor if editor is null in HTMLDocument * Ensure editor exists during live preview + modify unit test * Formatting fix
1 parent 85faca8 commit 6be6e29

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

src/LiveDevelopment/Documents/HTMLDocument.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,13 @@ define(function HTMLDocumentModule(require, exports, module) {
100100
*/
101101
HTMLDocument.prototype.getResponseData = function getResponseData(enabled) {
102102
var body;
103-
if (this._instrumentationEnabled && this.editor) {
104-
body = HTMLInstrumentation.generateInstrumentedHTML(this.editor);
103+
if (this._instrumentationEnabled) {
104+
if (this.editor) {
105+
body = HTMLInstrumentation.generateInstrumentedHTML(this.editor);
106+
} else {
107+
this.doc._ensureMasterEditor();
108+
body = HTMLInstrumentation.generateInstrumentedHTML(this.doc._masterEditor);
109+
}
105110
}
106111

107112
return {

test/spec/LiveDevelopment-test.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1103,7 +1103,9 @@ define(function (require, exports, module) {
11031103
it("should reload the page when editing a non-live document", function () {
11041104
var promise,
11051105
jsdoc,
1106-
loadEventPromise;
1106+
loadEventPromise,
1107+
liveDoc,
1108+
liveResponse;
11071109

11081110
runs(function () {
11091111
// Setup reload spy
@@ -1158,6 +1160,17 @@ define(function (require, exports, module) {
11581160
runs(function () {
11591161
expect(Inspector.Page.reload.callCount).toEqual(2);
11601162
});
1163+
1164+
waitForLiveDoc(tempDir + "/simple1.html", function (doc) {
1165+
liveDoc = doc;
1166+
liveResponse = doc.getResponseData();
1167+
});
1168+
1169+
runs(function () {
1170+
// Make sure a reload without an editor still sends back instrumented HTML
1171+
expect(liveDoc.editor).toBe(null);
1172+
expect(liveResponse.body.indexOf("data-brackets-id")).not.toBe(-1);
1173+
});
11611174
});
11621175

11631176
});

0 commit comments

Comments
 (0)