Commit 357955c2 authored by csillag's avatar csillag

Update d-t-m to ed0a7a85 (master branch)

This brings bugfixes for infinite loop on FF.

Fixes 1983.
parent ff95bd63
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
window.DomTextMapper = (function() { window.DomTextMapper = (function() {
var CONTEXT_LEN, SELECT_CHILDREN_INSTEAD, USE_EMPTY_TEXT_WORKAROUND, USE_TABLE_TEXT_WORKAROUND, WHITESPACE; var CONTEXT_LEN, SELECT_CHILDREN_INSTEAD, USE_EMPTY_TEXT_WORKAROUND, USE_TABLE_TEXT_WORKAROUND, WHITESPACE, WHITESPACE_REGEX;
DomTextMapper.applicable = function() { DomTextMapper.applicable = function() {
return true; return true;
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
CONTEXT_LEN = 32; CONTEXT_LEN = 32;
WHITESPACE_REGEX = /\s+/g;
DomTextMapper.instances = 0; DomTextMapper.instances = 0;
function DomTextMapper(id) { function DomTextMapper(id) {
...@@ -649,7 +651,7 @@ ...@@ -649,7 +651,7 @@
DomTextMapper.prototype.readSelectionText = function(sel) { DomTextMapper.prototype.readSelectionText = function(sel) {
sel || (sel = this.rootWin.getSelection()); sel || (sel = this.rootWin.getSelection());
return sel.toString().trim().replace(/\n/g, " ").replace(/\s{2,}/g, " "); return sel.toString().trim().replace(WHITESPACE_REGEX, ' ');
}; };
DomTextMapper.prototype.getNodeSelectionText = function(node, shouldRestoreSelection) { DomTextMapper.prototype.getNodeSelectionText = function(node, shouldRestoreSelection) {
...@@ -670,8 +672,8 @@ ...@@ -670,8 +672,8 @@
DomTextMapper.prototype.computeSourcePositions = function(match) { DomTextMapper.prototype.computeSourcePositions = function(match) {
var dc, displayEnd, displayIndex, displayStart, displayText, sc, sourceEnd, sourceIndex, sourceStart, sourceText; var dc, displayEnd, displayIndex, displayStart, displayText, sc, sourceEnd, sourceIndex, sourceStart, sourceText;
sourceText = match.element.node.data.replace(/\n/g, " "); sourceText = match.element.node.data.replace(WHITESPACE_REGEX, " ");
displayText = match.element.content; displayText = match.element.content.replace(WHITESPACE_REGEX, " ");
displayStart = match.start != null ? match.start : 0; displayStart = match.start != null ? match.start : 0;
displayEnd = match.end != null ? match.end : displayText.length; displayEnd = match.end != null ? match.end : displayText.length;
if (displayEnd === 0) { if (displayEnd === 0) {
...@@ -692,6 +694,8 @@ ...@@ -692,6 +694,8 @@
if (displayIndex === displayEnd) { if (displayIndex === displayEnd) {
sourceEnd = sourceIndex + 1; sourceEnd = sourceIndex + 1;
} }
} else if ((sc == null) || (dc == null)) {
throw new Error("display and source text mismatch: '" + sourceText + "' vs. '" + displayText + "'");
} }
sourceIndex++; sourceIndex++;
} }
...@@ -843,3 +847,5 @@ ...@@ -843,3 +847,5 @@
})(); })();
}).call(this); }).call(this);
//# sourceMappingURL=dom_text_mapper.map
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment