Merge "getAnnotationsFromRange should only ignore non-content data"

This commit is contained in:
jenkins-bot 2013-08-22 18:12:03 +00:00 committed by Gerrit Code Review
commit 9a7b7e9176
2 changed files with 23 additions and 7 deletions

View file

@ -433,9 +433,7 @@ ve.dm.ElementLinearData.prototype.getAnnotatedRangeFromSelection = function ( ra
* @returns {ve.dm.AnnotationSet} All annotation objects range is covered by
*/
ve.dm.ElementLinearData.prototype.getAnnotationsFromRange = function ( range, all ) {
var i,
left,
right;
var i, left, right;
// Look at left side of range for annotations
left = this.getAnnotationsFromOffset( range.start );
// Shortcut for single character and zero-length ranges
@ -444,8 +442,8 @@ ve.dm.ElementLinearData.prototype.getAnnotationsFromRange = function ( range, al
}
// Iterator over the range, looking for annotations, starting at the 2nd character
for ( i = range.start + 1; i < range.end; i++ ) {
// Skip non character data
if ( this.isElementData( i ) ) {
// Skip non-content data
if ( this.isElementData( i ) && !ve.dm.nodeFactory.isNodeContent( this.getType( i ) ) ) {
continue;
}
// Current character annotations

View file

@ -214,6 +214,24 @@ QUnit.test( 'getAnnotationsFromRange', 1, function ( assert ) {
],
'expected': []
},
{
'msg': 'no common coverage due to un-annotated content node',
'data': [
['a', [ { 'type': 'textStyle/bold' } ] ],
{ 'type': 'image' },
{ 'type': '/image' }
],
'expected': []
},
{
'msg': 'branch node is ignored',
'data': [
['a', [ { 'type': 'textStyle/bold' } ] ],
{ 'type': 'paragraph' },
{ 'type': '/paragraph' }
],
'expected': [ { 'type': 'textStyle/bold' } ]
},
{
'msg': 'annotations are collected using all with mismatched annotations',
'data': [
@ -284,8 +302,8 @@ QUnit.test( 'getAnnotationsFromRange', 1, function ( assert ) {
data = ve.dm.example.preprocessAnnotations( cases[i].data );
doc = new ve.dm.Document( data );
assert.deepEqual(
doc.data.getAnnotationsFromRange( new ve.Range( 0, cases[i].data.length ), cases[i].all ),
ve.dm.example.createAnnotationSet( doc.getStore(), cases[i].expected ),
doc.data.getAnnotationsFromRange( new ve.Range( 0, cases[i].data.length ), cases[i].all ).getIndexes(),
ve.dm.example.createAnnotationSet( doc.getStore(), cases[i].expected ).getIndexes(),
cases[i].msg
);
}