Merge "ve.dm.MWTemplateSpecModel: Expand parameter aliases"

This commit is contained in:
jenkins-bot 2013-06-24 01:02:56 +00:00 committed by Gerrit Code Review
commit 0a0265cb77
2 changed files with 17 additions and 7 deletions

View file

@ -67,16 +67,25 @@ ve.dm.MWTemplateSpecModel.getMessage = function ( val, fallback, lang ) {
* @param {string[][]} [data.sets] Lists of param sets
*/
ve.dm.MWTemplateSpecModel.prototype.extend = function ( data ) {
var key;
var key, paramObj, i, len;
if ( data.description !== null ) {
this.description = data.description;
}
if ( ve.isPlainObject( data.params ) ) {
for ( key in data.params ) {
paramObj = data.params[key];
this.params[key] = ve.extendObject(
true, this.getDefaultParameterSpec( key ), data.params[key]
true,
this.getDefaultParameterSpec( key ),
paramObj
);
if ( paramObj.aliases.length ) {
for ( i = 0, len = paramObj.aliases.length; i < len; i++ ) {
this.params[ paramObj.aliases[i] ] = paramObj;
}
}
delete paramObj.aliases;
}
}
if ( data.sets ) {

View file

@ -79,10 +79,10 @@ ve.dm.MWTransclusionModel.prototype.load = function ( data ) {
}
}
}
// Promise is resolved passing the specs object as the first argument - binding #specs
// to precede that argument and passing them both to extendObject will cause #specs to be added
// to when the promise is resolved
return this.fetchSpecs( templates ).done( ve.bind( ve.extendObject, null, this.specs ) );
// Add fetched specs to #specs store when the promise is resolved
return this.fetchSpecs( templates ).done( function ( specs ) {
ve.extendObject( this.specs, specs );
} );
};
/**
@ -92,7 +92,8 @@ ve.dm.MWTransclusionModel.prototype.load = function ( data ) {
* @returns {jQuery.Promise} Promise, resolved when spec is loaded
*/
ve.dm.MWTransclusionModel.prototype.fetchSpecs = function ( templates ) {
var i, len, title, deferred = $.Deferred(),
var i, len, title,
deferred = $.Deferred(),
specs = {},
titles = [];