mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-09-25 11:16:51 +00:00
Throw an error for bad offsets in getNodeFromOffset()
Will ease debugging of bug 40463 Change-Id: I3fbacb3e6e2f242c1584f51581d2b4e7c4bdd4dc
This commit is contained in:
parent
d9570ed0e5
commit
9488a38cca
|
@ -453,6 +453,9 @@ ve.dm.Document.prototype.getLength = function () {
|
|||
|
||||
ve.dm.Document.prototype.getNodeFromOffset = function ( offset ) {
|
||||
// FIXME duplicated from ve.ce.Document
|
||||
if ( offset < 0 || offset > this.data.length ) {
|
||||
throw new Error( 've.dm.Document.getNodeFromOffset(): offset ' + offset + ' is out of bounds' );
|
||||
}
|
||||
var node = this.documentNode.getNodeFromOffset( offset );
|
||||
if ( !node.canHaveChildren() ) {
|
||||
node = node.getParent();
|
||||
|
|
Loading…
Reference in a new issue