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

Commit

Permalink
- Fix bug with working set selection highlighting due to a danger-prone
Browse files Browse the repository at this point in the history
jQuery API that only accepts true booleans, not truthy/falsy
- Tiny improvement to Document.toString() readability
  • Loading branch information
peterflynn committed Mar 20, 2012
1 parent 930068a commit 6e84d05
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/DocumentManager.js
Expand Up @@ -547,7 +547,7 @@ define(function (require, exports, module) {
/* (pretty toString(), to aid debugging) */
Document.prototype.toString = function () {
var dirtyInfo = (this.isDirty ? " (dirty!)" : " (clean)");
var editorInfo = (this._masterEditor ? " Editable" : " Non-editable");
var editorInfo = (this._masterEditor ? " (Editable)" : " (Non-editable)");
var refInfo = " refs:" + this._refCount;
return "[Document " + this.file.fullPath + dirtyInfo + editorInfo + refInfo + "]";
};
Expand Down
10 changes: 6 additions & 4 deletions src/WorkingSetView.js
Expand Up @@ -49,7 +49,6 @@ define(function (require, exports, module) {
* @param {bool} canClose
*/
function _updateFileStatusIcon(listElement, isDirty, canClose) {

var fileStatusIcon = listElement.find(".file-status-icon");
var showIcon = isDirty || canClose;

Expand Down Expand Up @@ -77,8 +76,9 @@ define(function (require, exports, module) {

// Set icon's class
if (fileStatusIcon) {
fileStatusIcon.toggleClass("dirty", isDirty);
fileStatusIcon.toggleClass("canClose", canClose);
// cast to Boolean needed because toggleClass() distinguishes true/false from truthy/falsy
fileStatusIcon.toggleClass("dirty", Boolean(isDirty));
fileStatusIcon.toggleClass("canClose", Boolean(canClose));
}
}

Expand All @@ -90,7 +90,9 @@ define(function (require, exports, module) {
*/
function _updateListItemSelection(listItem, selectedDoc) {
var shouldBeSelected = (selectedDoc && $(listItem).data(_FILE_KEY).fullPath === selectedDoc.file.fullPath);
$(listItem).toggleClass("selected", shouldBeSelected);

// cast to Boolean needed because toggleClass() distinguishes true/false from truthy/falsy
$(listItem).toggleClass("selected", Boolean(shouldBeSelected));
}

function isOpenAndDirty(file) {
Expand Down

0 comments on commit 6e84d05

Please sign in to comment.