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
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,21 @@ define(function (require, exports, module) {
body = HTMLInstrumentation.generateInstrumentedHTML(this.editor, this.protocol.getRemoteScript());
}

if (!body) {
// generateInstrumentedHTML() returns null when the document is empty or its
// HTML cannot be parsed into a DOM (no instrumentable content). In that case it
// also never injected the remote <script>, so without help the served page would
// have no live-preview runtime at all — a blank page with no way to connect back
// or start editing. Fall back to the raw text but still inject the remote script
// so the runtime always loads, even for a completely empty page.
body = this.doc.getText();
if (this._instrumentationEnabled) {
body += this.protocol.getRemoteScript();
}
}

return {
body: body || this.doc.getText()
body: body
};
};

Expand Down
5 changes: 4 additions & 1 deletion src/nls/root/strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,12 @@ define({
"LIVE_DEV_INSERT_SEARCH_PLACEHOLDER": "Search elements\u2026",
"LIVE_DEV_INSERT_COMMON": "Common",
"LIVE_DEV_INSERT_NO_RESULTS": "No matching elements",
"LIVE_DEV_INSERT_SEE_MORE": "See more",
"LIVE_DEV_INSERT_SHOW_MORE": "Show more",
"LIVE_DEV_INSERT_SHOW_LESS": "Show less",
"LIVE_DEV_INSERT_CREATE": "Create",
"LIVE_DEV_EMPTY_CANVAS_LABEL": "Your page is empty — add an element",
"LIVE_DEV_EMPTY_CANVAS_ADD": "Add your first element",
"LIVE_DEV_EMPTY_CANVAS_COLLAPSE": "Collapse",
"LIVE_DEV_EDIT_ONBOARD_TITLE": "Two new ways to edit",
"LIVE_DEV_EDIT_ONBOARD_INSERT": "Add new HTML elements",
"LIVE_DEV_EDIT_ONBOARD_PROPS": "Edit tag, classes, ID and attributes",
Expand Down
Loading