Don't produce an invalid range

I know this code is still being worked on but I felt like I should put
this in anyway, it might save the person working on it some work

Change-Id: I1535399b3798cd8de2fc5334cd1eac64b71e8821
This commit is contained in:
Catrope 2012-06-14 19:34:30 -07:00
parent ef0c551b79
commit 7f97520af2

View file

@ -668,9 +668,15 @@ return;
} ); } );
// Create range surrounding the entire sourceNode and remove // Create range surrounding the entire sourceNode and remove
var range = new ve.Range(); /*var range = new ve.Range();
range.from = this.documentView.getDocumentNode().getOffsetFromNode( sourceNode ) range.from = this.documentView.getDocumentNode().getOffsetFromNode( sourceNode )
range.to = range.from + sourceNode.model.getOuterLength(); range.to = range.from + sourceNode.model.getOuterLength();*/
// Just setting .from and .to produces an invalid range with .start and .end unset --Roan
var from = this.documentView.getDocumentNode().getOffsetFromNode( sourceNode ),
range = new ve.Range(
from,
from + sourceNode.model.getOuterLength()
);
tx = ve.dm.Transaction.newFromRemoval( this.documentView.model, range ); tx = ve.dm.Transaction.newFromRemoval( this.documentView.model, range );
this.model.transact( tx ); this.model.transact( tx );
} }