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

Commit

Permalink
Merge pull request #3281 from adobe/randy/fix-livedev-tests
Browse files Browse the repository at this point in the history
Fix Live Dev unit tests due to HTMLDocument refactoring
  • Loading branch information
gruehle committed Mar 29, 2013
2 parents bcb5f41 + 2feafd9 commit d2f4bd4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
10 changes: 8 additions & 2 deletions src/LiveDevelopment/Documents/HTMLDocument.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ define(function HTMLDocumentModule(require, exports, module) {
* @param Document the source document from Brackets
*/
var HTMLDocument = function HTMLDocument(doc, editor) {
this.doc = doc;
if (!editor) {
return;
}
this.doc = doc;
this.editor = editor;

this.onCursorActivity = this.onCursorActivity.bind(this);
Expand Down Expand Up @@ -99,6 +99,9 @@ define(function HTMLDocumentModule(require, exports, module) {

/** Triggered on cursor activity by the editor */
HTMLDocument.prototype.onCursorActivity = function onCursorActivity(event, editor) {
if (!this.editor) {
return;
}
var codeMirror = this.editor._codeMirror;
if (LiveDevelopment.config.experimental && Inspector.config.highlight) {
var location = codeMirror.indexFromPos(codeMirror.getCursor());
Expand All @@ -109,6 +112,9 @@ define(function HTMLDocumentModule(require, exports, module) {

/** Triggered on change by the editor */
HTMLDocument.prototype.onChange = function onChange(event, editor, change) {
if (!this.editor) {
return;
}
var codeMirror = this.editor._codeMirror;
while (change) {
var from = codeMirror.indexFromPos(change.from);
Expand All @@ -121,7 +127,7 @@ define(function HTMLDocumentModule(require, exports, module) {

/** Triggered by the HighlightAgent to highlight a node in the editor */
HTMLDocument.prototype.onHighlight = function onHighlight(event, node) {
if (!node || !node.location) {
if (!node || !node.location || !this.editor) {
if (this._highlight) {
this._highlight.clear();
delete this._highlight;
Expand Down
6 changes: 5 additions & 1 deletion src/LiveDevelopment/LiveDevelopment.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,11 @@ define(function LiveDevelopment(require, exports, module) {
stylesheetDeferred.resolve();
})
.done(function (doc) {
if (!_liveDocument || (doc !== _liveDocument.doc)) {
// CSSAgent includes containing HTMLDocument in list returned
// from getStyleSheetURLS() (which could be useful for collecting
// embedded style sheets) but we need to filter doc out here.
if ((_classForDocument(doc) === CSSDocument) &&
(!_liveDocument || (doc !== _liveDocument.doc))) {
_setDocInfo(doc);
var liveDoc = _createDocument(doc);
if (liveDoc) {
Expand Down

0 comments on commit d2f4bd4

Please sign in to comment.