From: Ricordisamoa Date: Tue, 13 Oct 2015 16:07:36 +0000 (+0200) Subject: Use explicit methods instead of the jQuery constructor's second argument X-Git-Tag: 1.31.0-rc.0~9416 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/cotisations/rappels.php?a=commitdiff_plain;h=d83e8af56600172941a167f40ffa8372ad444872;p=lhc%2Fweb%2Fwiklou.git Use explicit methods instead of the jQuery constructor's second argument As recommended by https://www.mediawiki.org/wiki/Manual:Coding_conventions/JavaScript#Pitfalls: "As of jQuery 1.4 the jQuery constructor has a new feature that allows passing an object as second argument, like jQuery( '
', { foo: 'bar', click: function () {}, css: { .. } } );. Don't use this. It makes code harder to follow, fails on attributes (such as 'size') that are also methods, and is unstable due to this mixing of jQuery methods with element attributes. A future jQuery method or plugin or called "title" might convert an element into a heading, which means the title attribute can also no longer be set through this method. Be explicit and call .attr(), .prop(), .on() etc. directly." Change-Id: Iaf456b4b76dd4fc260dad0e4c0ec8f2976b59b83 --- diff --git a/resources/src/jquery/jquery.spinner.js b/resources/src/jquery/jquery.spinner.js index 41c555b71c..af5a97d6a4 100644 --- a/resources/src/jquery/jquery.spinner.js +++ b/resources/src/jquery/jquery.spinner.js @@ -67,7 +67,7 @@ opts = $.extend( {}, defaults, opts ); - var $spinner = $( '
', { 'class': 'mw-spinner', title: '...' } ); + var $spinner = $( '
' ).addClass( 'mw-spinner' ).attr( 'title', '...' ); if ( opts.id !== undefined ) { $spinner.attr( 'id', 'mw-spinner-' + opts.id ); } diff --git a/resources/src/mediawiki.action/mediawiki.action.view.metadata.js b/resources/src/mediawiki.action/mediawiki.action.view.metadata.js index 25b5acc5bc..b1a63b0506 100644 --- a/resources/src/mediawiki.action/mediawiki.action.view.metadata.js +++ b/resources/src/mediawiki.action/mediawiki.action.view.metadata.js @@ -21,10 +21,10 @@ $row = $( '' ); $col = $( '' ); - $link = $( '', { - text: showText, - href: '#' - } ).click( function () { + $link = $( '' ) + .text( showText ) + .attr( 'href', '#' ) + .click( function () { if ( $table.hasClass( 'collapsed' ) ) { $( this ).text( hideText ); } else {