mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 18:39:52 +00:00
Make method ve.dm.Document.addAnnotationsToData accept collection of annotations as a param - instead of an array
This commit is contained in:
parent
429225fb57
commit
81473a8119
|
@ -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 );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue