Merge "Simplify tofu detection cache"

This commit is contained in:
jenkins-bot
2014-04-01 11:30:07 +00:00
committed by Gerrit Code Review

View File

@@ -142,7 +142,7 @@
* @param {array} classes * @param {array} classes
*/ */
fontSelector: function ( repository, language, classes ) { fontSelector: function ( repository, language, classes ) {
var font, tofu, autonym, defaultFont; var font, autonym, defaultFont;
if ( !language ) { if ( !language ) {
return null; return null;
@@ -164,19 +164,17 @@
// There is a default font for this language, // There is a default font for this language,
// but check whether the user sees tofu for it. // but check whether the user sees tofu for it.
tofu = tofuLanguages[language] || if ( tofuLanguages[language] === undefined ) {
detectTofu( $.uls.data.getAutonym( language ) ); tofuLanguages[language] = detectTofu( $.uls.data.getAutonym( language ) );
if ( tofu ) {
// Log the tofu detection only once per page per language // Log the tofu detection only once per page per language
if ( !tofuLanguages[language] ) { if ( tofuLanguages[language] ) {
mw.log( 'tofu detected for ' + language ); mw.log( 'tofu detected for ' + language );
mw.hook( 'mw.uls.webfonts.tofudetected' ).fire( language ); mw.hook( 'mw.uls.webfonts.tofudetected' ).fire( language );
}
// Cache the languages with tofu
tofuLanguages[language] = true;
} }
if ( tofuLanguages[language] ) {
font = autonym ? 'Autonym' : defaultFont; font = autonym ? 'Autonym' : defaultFont;
} else { } else {
// No tofu and no font preference. Use system font. // No tofu and no font preference. Use system font.