jenkins-bot has submitted this change and it was merged.

Change subject: Fix JavaScript error on pages without headings
......................................................................


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
---
M resources/js/ext.uls.webfonts.js
1 file changed, 14 insertions(+), 17 deletions(-)

Approvals:
  Amire80: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/resources/js/ext.uls.webfonts.js b/resources/js/ext.uls.webfonts.js
index 9bc30ca..745549a 100644
--- a/resources/js/ext.uls.webfonts.js
+++ b/resources/js/ext.uls.webfonts.js
@@ -129,18 +129,14 @@
                $.extend( $.fn.webfonts.defaults, {
                        repository: mediawikiFontRepository,
                        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
-                         * on the given language and html classes and user 
preference.
-                         *
-                         * @param {Object} repository
-                         * @param {string} language
-                         * @param {array} classes
-                         */
+                       /**
+                        * Returns a suitable font from font repository based
+                        * on the given language and html classes and user 
preference.
+                        *
+                        * @param {Object} repository
+                        * @param {string} language
+                        * @param {array} classes
+                        */
                        fontSelector: function ( repository, language, classes 
) {
                                var font, autonym, defaultFont;
 
@@ -191,19 +187,20 @@
                        },
 
                        exclude: ( function () {
-                               var excludes = $.fn.webfonts.defaults.exclude;
+                               var excludes = mw.config.get( 
'wgULSNoWebfontsSelectors' ).join( ', ' );
 
                                if ( mw.user.options.get( 'editfont' ) !== 
'default' ) {
                                        // Exclude textboxes from webfonts if 
the user has edit area font option
                                        // set using 'Preferences' page
-                                       excludes = ( excludes ) ?
-                                               excludes + ',textarea' :
-                                               'textarea';
+                                       excludes = excludes ? excludes + 
',textarea' : 'textarea';
                                }
 
                                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.

-- 
To view, visit https://gerrit.wikimedia.org/r/172022
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ic33f3934166f4feb6dd088ca0d14e249fcf237a3
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/UniversalLanguageSelector
Gerrit-Branch: master
Gerrit-Owner: Nikerabbit <niklas.laxst...@gmail.com>
Gerrit-Reviewer: Amire80 <amir.ahar...@mail.huji.ac.il>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to