mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-28 00:00:49 +00:00
Normalize to template namespace when comparing
Bug: T169307 Change-Id: Ic3524819fb026713b27b193e4a03338fffd97229
This commit is contained in:
parent
9986166cfb
commit
b3d44c1ccd
|
@ -339,10 +339,12 @@ ve.dm.MWTransclusionNode.prototype.onAttributeChange = function ( key ) {
|
|||
* @return {boolean} Transclusion only contains a single template, which is one of the ones in templates
|
||||
*/
|
||||
ve.dm.MWTransclusionNode.prototype.isSingleTemplate = function ( templates ) {
|
||||
var i, len, partsList = this.getPartsList();
|
||||
var i, len,
|
||||
templateNS = mw.config.get( 'wgNamespaceIds' ).template,
|
||||
partsList = this.getPartsList();
|
||||
|
||||
function normalizeTitle( name ) {
|
||||
var title = mw.Title.newFromText( name );
|
||||
function normalizeTemplateTitle( name ) {
|
||||
var title = mw.Title.newFromText( name, templateNS );
|
||||
return title ? title.getPrefixedText() : name;
|
||||
}
|
||||
|
||||
|
@ -358,7 +360,7 @@ ve.dm.MWTransclusionNode.prototype.isSingleTemplate = function ( templates ) {
|
|||
for ( i = 0, len = templates.length; i < len; i++ ) {
|
||||
if (
|
||||
partsList[ 0 ].templatePage &&
|
||||
partsList[ 0 ].templatePage === normalizeTitle( templates[ i ] )
|
||||
partsList[ 0 ].templatePage === normalizeTemplateTitle( templates[ i ] )
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue