-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Live Preview - Fix currentDocumentChange handling #4969
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -238,7 +238,9 @@ define(function LiveDevelopment(require, exports, module) { | |
| } | ||
|
|
||
| // Clear all documents from request filtering | ||
| _server.clear(); | ||
| if (_server) { | ||
| _server.clear(); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -533,8 +535,6 @@ define(function LiveDevelopment(require, exports, module) { | |
| // No longer in site, so terminate live dev, but don't close browser window | ||
| Inspector.disconnect(); | ||
| _closeReason = "navigated_away"; | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should have been handled in the |
||
| _setStatus(STATUS_INACTIVE); | ||
| _server = null; | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -545,12 +545,17 @@ define(function LiveDevelopment(require, exports, module) { | |
|
|
||
| unloadAgents(); | ||
|
|
||
| // Stop listening for requests when disconnected | ||
| _server.stop(); | ||
|
|
||
| // Close live documents | ||
| _closeDocuments(); | ||
|
|
||
| if (_server) { | ||
| // Stop listening for requests when disconnected | ||
| _server.stop(); | ||
|
|
||
| // Dispose server | ||
| _server = null; | ||
| } | ||
|
|
||
| _setStatus(STATUS_INACTIVE); | ||
| } | ||
|
|
||
|
|
@@ -593,11 +598,15 @@ define(function LiveDevelopment(require, exports, module) { | |
| } | ||
|
|
||
| if (Inspector.connected()) { | ||
| var timer = window.setTimeout(cleanup, 5000); // 5 seconds | ||
| Inspector.Runtime.evaluate("window.open('', '_self').close();", function (response) { | ||
| Inspector.disconnect(); | ||
| window.clearTimeout(timer); | ||
| cleanup(); | ||
| // Close the browser tab/window | ||
| var closePromise = Inspector.Runtime.evaluate("window.open('', '_self').close();"); | ||
|
|
||
| // Add a timeout to force cleanup if Inspector does not respond | ||
| closePromise = Async.withTimeout(closePromise, 5000); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cleanup: Use |
||
|
|
||
| // Disconnect the Inspector after closing the tab/winow | ||
| closePromise.always(function () { | ||
| Inspector.disconnect().always(cleanup); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix async bug where |
||
| }); | ||
| } else { | ||
| cleanup(); | ||
|
|
@@ -922,23 +931,21 @@ define(function LiveDevelopment(require, exports, module) { | |
| function _onDocumentChange() { | ||
| var doc = _getCurrentDocument(); | ||
|
|
||
| if (!doc) { | ||
| if (!doc || !Inspector.connected()) { | ||
| return; | ||
| } | ||
|
|
||
| if (Inspector.connected()) { | ||
| hideHighlight(); | ||
|
|
||
| // close the current session and begin a new session if the current | ||
| // document changes to an HTML document that was not loaded yet | ||
| var wasRequested = agents.network && agents.network.wasURLRequested(doc.url), | ||
| isHTML = exports.config.experimental || _isHtmlFileExt(doc.extension); | ||
|
|
||
| if (!wasRequested && isHTML) { | ||
| // TODO (jasonsanjose): optimize this by reusing the same connection | ||
| // no need to fully teardown. | ||
| close().done(open); | ||
| } | ||
| hideHighlight(); | ||
|
|
||
| // close the current session and begin a new session if the current | ||
| // document changes to an HTML document that was not loaded yet | ||
| var wasRequested = agents.network && agents.network.wasURLRequested(doc.url), | ||
| isViewable = exports.config.experimental || _server.canServe(doc.file.fullPath); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move to |
||
|
|
||
| if (!wasRequested && isViewable) { | ||
| // TODO (jasonsanjose): optimize this by reusing the same connection | ||
| // no need to fully teardown. | ||
| close().done(open); | ||
| } | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are two entries for
rel="stylesheet"