mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-09-27 04:06:51 +00:00
Merge "ve.dm.MWTemplateSpecModel: Expand parameter aliases"
This commit is contained in:
commit
0a0265cb77
|
@ -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 ) {
|
||||
|
|
|
@ -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 = [];
|
||||
|
||||
|
|
Loading…
Reference in a new issue