Merge "Better name for spec.isParameterKnown() method"

This commit is contained in:
jenkins-bot 2021-06-28 10:36:25 +00:00 committed by Gerrit Code Review
commit 73c79d74c0
4 changed files with 11 additions and 15 deletions

View file

@ -167,7 +167,7 @@ ve.dm.MWTemplateModel.prototype.hasParameter = function ( name ) {
}
// Check if the name is known at all
if ( !this.spec.isParameterKnown( name ) ) {
if ( !this.spec.isKnownParameterOrAlias( name ) ) {
return false;
}
@ -361,7 +361,7 @@ ve.dm.MWTemplateModel.prototype.serialize = function () {
// …unless they were present before the edit
!Object.prototype.hasOwnProperty.call( origParams, name ) &&
// …unless they are required (T276989)
!( spec.isParameterKnown( name ) && spec.isParameterRequired( name ) )
!( spec.isKnownParameterOrAlias( name ) && spec.isParameterRequired( name ) )
) {
continue;
}

View file

@ -178,14 +178,10 @@ ve.dm.MWTemplateSpecModel.prototype.getCanonicalParameterOrder = function () {
};
/**
* Check if a parameter name is known.
*
* Could be a primary name or alias.
*
* @param {string} name Parameter name
* @return {boolean} Parameter name is known
* @param {string} name Parameter name or alias
* @return {boolean}
*/
ve.dm.MWTemplateSpecModel.prototype.isParameterKnown = function ( name ) {
ve.dm.MWTemplateSpecModel.prototype.isKnownParameterOrAlias = function ( name ) {
return this.params[ name ] !== undefined;
};

View file

@ -30,7 +30,7 @@
assert.strictEqual( spec.getLabel(), 'RawTemplateName', 'getLabel' );
assert.strictEqual( spec.getDescription(), null, 'getDescription' );
assert.deepEqual( spec.getCanonicalParameterOrder(), [], 'getCanonicalParameterOrder' );
assert.strictEqual( spec.isParameterKnown( 'unknown' ), false, 'isParameterKnown' );
assert.strictEqual( spec.isKnownParameterOrAlias( 'unknown' ), false, 'isKnownParameterOrAlias' );
assert.strictEqual( spec.getParameterDefaultValue( 'unknown' ), '', 'getParameterDefaultValue' );
assert.strictEqual( spec.getParameterAutoValue( 'unknown' ), '', 'getParameterAutoValue' );
assert.deepEqual( spec.getParameterNames(), [], 'getParameterNames' );
@ -45,7 +45,7 @@
assert.strictEqual( spec.getLabel(), 'RawTemplateName', 'getLabel' );
assert.strictEqual( spec.getDescription(), null, 'getDescription' );
assert.deepEqual( spec.getCanonicalParameterOrder(), [], 'getCanonicalParameterOrder' );
assert.strictEqual( spec.isParameterKnown( 'p2' ), true, 'isParameterKnown' );
assert.strictEqual( spec.isKnownParameterOrAlias( 'p2' ), true, 'isKnownParameterOrAlias' );
assert.strictEqual( spec.isParameterAlias( 'p2' ), false, 'isParameterAlias' );
assert.strictEqual( spec.getParameterLabel( 'p2' ), 'p2', 'getParameterLabel' );
assert.strictEqual( spec.getParameterDescription( 'p2' ), null, 'getParameterDescription' );
@ -75,7 +75,7 @@
assert.strictEqual( spec.getLabel(), 'RawTemplateName', 'getLabel' );
assert.strictEqual( spec.getDescription(), null, 'getDescription' );
assert.deepEqual( spec.getCanonicalParameterOrder(), [], 'getCanonicalParameterOrder' );
assert.strictEqual( spec.isParameterKnown( 'p2' ), true, 'isParameterKnown' );
assert.strictEqual( spec.isKnownParameterOrAlias( 'p2' ), true, 'isKnownParameterOrAlias' );
assert.strictEqual( spec.isParameterAlias( 'p2' ), false, 'isParameterAlias' );
assert.strictEqual( spec.getParameterLabel( 'p2' ), 'p2', 'getParameterLabel' );
assert.strictEqual( spec.getParameterDescription( 'p2' ), null, 'getParameterDescription' );
@ -104,7 +104,7 @@
assert.strictEqual( spec.getLabel(), 'RawTemplateName', 'getLabel' );
assert.strictEqual( spec.getDescription(), undefined, 'getDescription' );
assert.deepEqual( spec.getCanonicalParameterOrder(), [ 'p2' ], 'getCanonicalParameterOrder' );
assert.strictEqual( spec.isParameterKnown( 'p2' ), true, 'isParameterKnown' );
assert.strictEqual( spec.isKnownParameterOrAlias( 'p2' ), true, 'isKnownParameterOrAlias' );
assert.strictEqual( spec.isParameterAlias( 'p2' ), false, 'isParameterAlias' );
assert.strictEqual( spec.getParameterLabel( 'p2' ), 'p2', 'getParameterLabel' );
assert.strictEqual( spec.getParameterDescription( 'p2' ), null, 'getParameterDescription' );
@ -153,7 +153,7 @@
assert.strictEqual( spec.getLabel(), 'RawTemplateName', 'getLabel' );
assert.strictEqual( spec.getDescription(), 'TemplateDescription', 'getDescription' );
assert.deepEqual( spec.getCanonicalParameterOrder(), [ 'DummyOrder' ], 'getCanonicalParameterOrder' );
assert.strictEqual( spec.isParameterKnown( 'a' ), true, 'isParameterKnown' );
assert.strictEqual( spec.isKnownParameterOrAlias( 'a' ), true, 'isKnownParameterOrAlias' );
assert.strictEqual( spec.isParameterAlias( 'a' ), true, 'isParameterAlias' );
assert.strictEqual( spec.getParameterLabel( 'a' ), 'ParamLabel', 'getParameterLabel' );
assert.strictEqual( spec.getParameterDescription( 'a' ), 'ParamDescription', 'getParameterDescription' );

View file

@ -89,7 +89,7 @@ ve.ui.MWParameterPlaceholderPage.prototype.onParameterChoose = function ( name )
}
// Note that every parameter is known after it is added
var knownBefore = this.template.getSpec().isParameterKnown( name ),
var knownBefore = this.template.getSpec().isKnownParameterOrAlias( name ),
param = new ve.dm.MWParameterModel( this.template, name );
this.addParameterSearch.query.setValue( '' );