diff --git a/modules/ve-mw/dm/models/ve.dm.MWTemplateModel.js b/modules/ve-mw/dm/models/ve.dm.MWTemplateModel.js index 6148bdcfdc..a22006a8ab 100644 --- a/modules/ve-mw/dm/models/ve.dm.MWTemplateModel.js +++ b/modules/ve-mw/dm/models/ve.dm.MWTemplateModel.js @@ -183,17 +183,16 @@ ve.dm.MWTemplateModel.prototype.hasParameter = function ( name ) { * unrelated to how the parameters appear in the wikitext. Parameter names and aliases documented * via TemplateData are first, in their documented order. Undocumented parameters are sorted with * numeric names first, followed by alphabetically sorted names. The unnamed placeholder parameter - * is last. Parameters that are deprecated and do not have a value are filtered out. + * is last. * * @return {string[]} */ ve.dm.MWTemplateModel.prototype.getAllParametersOrdered = function () { var spec = this.spec, - params = this.params, parameters = spec.getCanonicalParameterOrder(); // Restore aliases originally used in the wikitext. The spec doesn't know which alias was used. - Object.keys( params ).forEach( function ( name ) { + for ( var name in this.params ) { if ( spec.isParameterAlias( name ) ) { parameters.splice( // This can never fail because only documented parameters can have aliases @@ -202,23 +201,11 @@ ve.dm.MWTemplateModel.prototype.getAllParametersOrdered = function () { name ); } - } ); - - // Restore the placeholder, if present. The spec doesn't keep track of placeholders. - if ( '' in params ) { - parameters.push( '' ); } - // Remove deprecated parameters, if they do not have a value. - if ( mw.config.get( 'wgVisualEditorConfig' ).transclusionDialogNewSidebar ) { - parameters = parameters.filter( function ( name ) { - if ( spec.isParameterDeprecated( name ) ) { - if ( !params[ name ] || !this.originalData.params[ name ].wt ) { - return false; - } - } - return true; - }, this ); + // Restore the placeholder, if present. The spec doesn't keep track of placeholders. + if ( '' in this.params ) { + parameters.push( '' ); } // TODO: cache results diff --git a/modules/ve-mw/tests/dm/ve.dm.MWTemplateModel.test.js b/modules/ve-mw/tests/dm/ve.dm.MWTemplateModel.test.js index 7066093a37..e8489d4ac2 100644 --- a/modules/ve-mw/tests/dm/ve.dm.MWTemplateModel.test.js +++ b/modules/ve-mw/tests/dm/ve.dm.MWTemplateModel.test.js @@ -34,15 +34,6 @@ return ve.dm.MWTemplateModel.newFromData( transclusion, clonedTransclusionData ); } - /** - * @param {boolean} enabled - */ - function enableNewSidebar( enabled ) { - const config = mw.config.get( 'wgVisualEditorConfig' ); - config.transclusionDialogNewSidebar = enabled !== false; - mw.config.set( 'wgVisualEditorConfig', config ); - } - /* Tests */ QUnit.test( 'hasParameter', ( assert ) => { @@ -412,117 +403,4 @@ assert.deepEqual( template.getAllParametersOrdered(), expected ); } ); } ); - - [ - { - name: 'spec with explicit paramOrder and a deprecated param that has a value', - spec: { - params: { - empty: {}, - unused: {}, - foo: { - deprecated: true - } - }, - paramOrder: [ 'foo', 'empty', 'unused' ] - }, - expected: [ - 'foo', - 'empty', - 'unused', - 'bar', - '' - ] - }, - { - name: 'spec with explicit paramOrder and a deprecated param that does not have a value', - spec: { - params: { - empty: { - deprecated: true - }, - unused: {}, - foo: {} - }, - paramOrder: [ 'foo', 'empty', 'unused' ] - }, - expected: [ - 'foo', - 'unused', - 'bar', - '' - ] - }, - { - name: 'spec with explicit paramOrder and an aliased deprecated param that does have a value', - spec: { - params: { - empty: {}, - unused: {}, - hasalias: { - deprecated: true, - aliases: [ 'bar' ] - } - }, - paramOrder: [ 'hasalias', 'empty', 'unused' ] - }, - expected: [ - 'bar', - 'empty', - 'unused', - 'foo', - '' - ] - }, - { - name: 'spec with explicit paramOrder and an aliased deprecated param that does not have a value', - spec: { - params: { - foo: {}, - unused: {}, - hasalias: { - deprecated: true, - aliases: [ 'empty' ] - } - }, - paramOrder: [ 'hasalias', 'foo', 'unused' ] - }, - expected: [ - 'foo', - 'unused', - 'bar', - '' - ] - }, - { - name: 'spec with no paramOrder and a deprecated param that does not have a value', - spec: { - params: { - empty: { - deprecated: true - }, - unused: {}, - foo: {} - } - }, - expected: [ - 'unused', - 'foo', - 'bar', - '' - ] - } - ].forEach( ( { name, spec, expected } ) => { - QUnit.test( 'getAllParametersOrdered: transclusionDialogNewSidebar: ' + name, ( assert ) => { - enableNewSidebar( true ); - const template = newTemplateModel(); - - if ( spec ) { - template.getSpec().setTemplateData( spec ); - } - - assert.deepEqual( template.getAllParametersOrdered(), expected ); - enableNewSidebar( false ); - } ); - } ); }() );