Merge "Don't try to prefix browser title if a custom message is incompatible"

This commit is contained in:
jenkins-bot 2023-06-15 05:45:53 +00:00 committed by Gerrit Code Review
commit 2d9e31e0e5

View file

@ -990,24 +990,32 @@ ve.init.mw.DesktopArticleTarget.prototype.teardownToolbar = function () {
*/
ve.init.mw.DesktopArticleTarget.prototype.changeDocumentTitle = function () {
var title = mw.Title.newFromText( this.getPageName() );
// Use the real title if we loaded a view page, otherwise reconstruct it
this.originalDocumentTitle = this.isViewPage ? document.title : ve.msg( 'pagetitle', title.getPrefixedText() );
// Reconstruct an edit title
document.title = ve.msg( 'pagetitle',
var pageTitleMsg = mw.message( 'pagetitle',
ve.msg(
this.pageExists ? 'editing' : 'creating',
title.getPrefixedText()
)
);
// T317600
if ( pageTitleMsg.isParseable() ) {
// Use the real title if we loaded a view page, otherwise reconstruct it
this.originalDocumentTitle = this.isViewPage ? document.title : ve.msg( 'pagetitle', title.getPrefixedText() );
// Reconstruct an edit title
document.title = pageTitleMsg.text();
} else {
mw.log.warn( 'VisualEditor: MediaWiki:Pagetitle contains unsupported syntax. ' +
'https://www.mediawiki.org/wiki/Manual:Messages_API#Feature_support_in_JavaScript' );
}
};
/**
* Restore the original document title.
*/
ve.init.mw.DesktopArticleTarget.prototype.restoreDocumentTitle = function () {
document.title = this.originalDocumentTitle;
if ( this.originalDocumentTitle ) {
document.title = this.originalDocumentTitle;
}
};
/**