Make method ve.dm.Document.addAnnotationsToData accept collection of annotations as a param - instead of an array

This commit is contained in:
Inez Korczynski 2012-06-13 16:23:19 -07:00
parent 429225fb57
commit 81473a8119

View file

@ -158,21 +158,12 @@ ve.dm.Document = function( data, parentDocument ) {
* @param {Array} annotations Annotations to apply * @param {Array} annotations Annotations to apply
*/ */
ve.dm.Document.addAnnotationsToData = function( data, annotations ) { ve.dm.Document.addAnnotationsToData = function( data, annotations ) {
if ( !annotations || annotations.length === 0 ) {
return;
}
var annotationMap = {},
i;
// Build annotation map
for ( i = 0; i < annotations.length; i++ ) {
annotationMap[ve.getHash( annotations[i] )] = annotations[i];
}
// Apply annotations to data // Apply annotations to data
for ( i = 0; i < data.length; i++ ) { for ( i = 0; i < data.length; i++ ) {
if ( !ve.isArray( data[i] ) ) { if ( !ve.isArray( data[i] ) ) {
data[i] = [data[i]]; data[i] = [data[i]];
} }
data[i][1] = ve.extendObject( data[i][1], annotationMap ); data[i][1] = ve.extendObject( data[i][1], annotations );
} }
}; };