Fix JavaScript error on pages without headings

Error was caused because .css( 'font-family' ) returns undefined for
elements which do not exist.

Merged two blocks both extending the default settings.

Bug: 67676
Change-Id: Ic33f3934166f4feb6dd088ca0d14e249fcf237a3
This commit is contained in:
Niklas Laxström
2014-11-08 11:47:33 +01:00
committed by Amire80
parent 34eafa99f1
commit 4a09ed96d5

View File

@@ -129,10 +129,6 @@
$.extend( $.fn.webfonts.defaults, { $.extend( $.fn.webfonts.defaults, {
repository: mediawikiFontRepository, repository: mediawikiFontRepository,
fontStack: $( 'body' ).css( 'font-family' ).split( /, /g ), fontStack: $( 'body' ).css( 'font-family' ).split( /, /g ),
exclude: mw.config.get( 'wgULSNoWebfontsSelectors' ).join( ', ' )
} );
$.fn.webfonts.defaults = $.extend( $.fn.webfonts.defaults, {
/** /**
* Returns a suitable font from font repository based * Returns a suitable font from font repository based
* on the given language and html classes and user preference. * on the given language and html classes and user preference.
@@ -191,19 +187,20 @@
}, },
exclude: ( function () { exclude: ( function () {
var excludes = $.fn.webfonts.defaults.exclude; var excludes = mw.config.get( 'wgULSNoWebfontsSelectors' ).join( ', ' );
if ( mw.user.options.get( 'editfont' ) !== 'default' ) { if ( mw.user.options.get( 'editfont' ) !== 'default' ) {
// Exclude textboxes from webfonts if the user has edit area font option // Exclude textboxes from webfonts if the user has edit area font option
// set using 'Preferences' page // set using 'Preferences' page
excludes = ( excludes ) ? excludes = excludes ? excludes + ',textarea' : 'textarea';
excludes + ',textarea' :
'textarea';
} }
return excludes; return excludes;
}() ), }() ),
overridableFontFamilies: [ $( 'h1' ).css( 'font-family' ) ] overridableFontFamilies: ( function () {
var headingFont = $( 'h1' ).css( 'font-family' );
return headingFont ? [ headingFont ] : [];
}() )
} ); } );
// Execute after task queue is processed so that the rendering is complete. // Execute after task queue is processed so that the rendering is complete.