Skip to content

Commit

Permalink
Fix #705: Selection: reset range if start node was unrendered
Browse files Browse the repository at this point in the history
When OnDemandList destroys far-off nodes, it can cause problems for
Selection and CellSelection if a long range selection is made after the
original start of the range was removed from the DOM.  This fix prevents
that case from throwing an error, though the range will still be reset.
  • Loading branch information
Kenneth G. Franqueiro committed Dec 27, 2013
1 parent aef5e01 commit e3fc0a2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
12 changes: 11 additions & 1 deletion CellSelection.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,20 @@ return declare(Selection, {
this._selectionEventQueues[(value ? "" : "de") + "select"].push(cell);
}
if(toCell){
// a range
if(!toCell.element){
toCell = this.cell(toCell);
}

if(!toCell || !toCell.row){
this._lastSelected = element;
console.warn("The selection range has been reset because the " +
"beginning of the selection is no longer in the DOM. " +
"If you are using OnDemandList, you may wish to increase " +
"farOffRemoval to avoid this, but note that keeping more nodes " +
"in the DOM may impact performance.");
return;
}

var toElement = toCell.element;
var fromElement = cell.element;
// find if it is earlier or later in the DOM
Expand Down
11 changes: 11 additions & 0 deletions Selection.js
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,17 @@ return declare(null, {
if(!toRow.element){
toRow = this.row(toRow);
}

if(!toRow){
this._lastSelected = element;
console.warn("The selection range has been reset because the " +
"beginning of the selection is no longer in the DOM. " +
"If you are using OnDemandList, you may wish to increase " +
"farOffRemoval to avoid this, but note that keeping more nodes " +
"in the DOM may impact performance.");
return;
}

toElement = toRow.element;
// find if it is earlier or later in the DOM
traverser = (toElement && (toElement.compareDocumentPosition ?
Expand Down

0 comments on commit e3fc0a2

Please sign in to comment.