From eabea2e23ee35cfd4cd460d6c48cb04d740d80ce Mon Sep 17 00:00:00 2001 From: Jason Cheatham Date: Fri, 20 Dec 2013 21:36:39 -0500 Subject: [PATCH] Don't throw exception for large select ranges Selection can't currently handle large selection ranges because it drops nodes that are far away from the currently visible range. Emit a warning rather than throwing an exception when this happens. Fixes #705 (sort of) --- Selection.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/Selection.js b/Selection.js index cb14ab3cd..1b57c87e5 100644 --- a/Selection.js +++ b/Selection.js @@ -500,13 +500,17 @@ return declare(null, { if(!toRow.element){ toRow = this.row(toRow); } - toElement = toRow.element; - // find if it is earlier or later in the DOM - traverser = (toElement && (toElement.compareDocumentPosition ? - toElement.compareDocumentPosition(element) == 2 : - toElement.sourceIndex > element.sourceIndex)) ? "down" : "up"; - while(row.element != toElement && (row = this[traverser](row))){ - this._select(row, null, value); + if(toRow){ + toElement = toRow.element; + // find if it is earlier or later in the DOM + traverser = (toElement && (toElement.compareDocumentPosition ? + toElement.compareDocumentPosition(element) == 2 : + toElement.sourceIndex > element.sourceIndex)) ? "down" : "up"; + while(row.element != toElement && (row = this[traverser](row))){ + this._select(row, null, value); + } + }else{ + console.warn('select range too large') } } }