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

Commit d706cf2

Browse files
committed
code review comments
1 parent eed9aac commit d706cf2

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

src/LiveDevelopment/Documents/CSSDocument.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ define(function CSSDocumentModule(require, exports, module) {
7373
$(this.doc).on("deleted.CSSDocument", this.onDeleted);
7474

7575
this.onActiveEditorChange = this.onActiveEditorChange.bind(this);
76-
$(EditorManager).on("activeEditorChange.CSSDocument", this.onActiveEditorChange);
76+
$(EditorManager).on("activeEditorChange", this.onActiveEditorChange);
7777

7878
if (editor) {
7979
// Attach now
@@ -113,9 +113,8 @@ define(function CSSDocumentModule(require, exports, module) {
113113

114114
/** Close the document */
115115
CSSDocument.prototype.close = function close() {
116-
$(this.doc).off("change.CSSDocument");
117-
$(this.doc).off("deleted.CSSDocument");
118-
$(EditorManager).off("activeEditorChange.CSSDocument");
116+
$(this.doc).off(".CSSDocument");
117+
$(EditorManager).off("activeEditorChange", this.onActiveEditorChange);
119118
this.doc.releaseRef();
120119
this.detachFromEditor();
121120
};
@@ -137,7 +136,7 @@ define(function CSSDocumentModule(require, exports, module) {
137136
this.editor = editor;
138137

139138
if (this.editor) {
140-
$(HighlightAgent).on("highlight.CSSDocument", this.onHighlight);
139+
$(HighlightAgent).on("highlight", this.onHighlight);
141140
$(this.editor).on("cursorActivity.CSSDocument", this.onCursorActivity);
142141
this.updateHighlight();
143142
}
@@ -146,8 +145,8 @@ define(function CSSDocumentModule(require, exports, module) {
146145
CSSDocument.prototype.detachFromEditor = function () {
147146
if (this.editor) {
148147
HighlightAgent.hide();
149-
$(HighlightAgent).off("highlight.CSSDocument");
150-
$(this.editor).off("cursorActivity.CSSDocument");
148+
$(HighlightAgent).off("highlight", this.onHighlight);
149+
$(this.editor).off(".CSSDocument");
151150
this.onHighlight();
152151
this.editor = null;
153152
}

src/LiveDevelopment/LiveDevelopment.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,10 @@ define(function LiveDevelopment(require, exports, module) {
213213

214214
if (index !== -1) {
215215
_relatedDocuments.splice(index, 1);
216-
_server.remove(liveDoc);
216+
217+
if (_server) {
218+
_server.remove(liveDoc);
219+
}
217220
}
218221
}
219222

@@ -266,7 +269,7 @@ define(function LiveDevelopment(require, exports, module) {
266269
function createLiveStylesheet(url) {
267270
var stylesheetDeferred = $.Deferred(),
268271
promise = stylesheetDeferred.promise(),
269-
path = _server.urlToPath(url);
272+
path = _server && _server.urlToPath(url);
270273

271274
// path may be null if loading an external stylesheet
272275
if (path) {
@@ -998,7 +1001,7 @@ define(function LiveDevelopment(require, exports, module) {
9981001
// close the current session and begin a new session if the current
9991002
// document changes to an HTML document that was not loaded yet
10001003
var wasRequested = agents.network && agents.network.wasURLRequested(doc.url),
1001-
isViewable = exports.config.experimental || _server.canServe(doc.file.fullPath);
1004+
isViewable = exports.config.experimental || (_server && _server.canServe(doc.file.fullPath));
10021005

10031006
if (!wasRequested && isViewable) {
10041007
// TODO (jasonsanjose): optimize this by reusing the same connection

0 commit comments

Comments
 (0)