caching selector instead of re-creating the jQuery object for 'this' two or three...
authorKrinkle <krinkle@users.mediawiki.org>
Thu, 24 Feb 2011 23:02:56 +0000 (23:02 +0000)
committerKrinkle <krinkle@users.mediawiki.org>
Thu, 24 Feb 2011 23:02:56 +0000 (23:02 +0000)
resources/jquery/jquery.localize.js

index 27d6584..15e0164 100644 (file)
@@ -37,22 +37,24 @@ $.fn.localize = function( options ) {
                .find( 'msg,html\\:msg' )
                        .each( function() {
                                var $el = $(this);
-                               $(this)
-                                       .text( mw.msg( options.prefix + $(this).attr( 'key' ) ) )
-                                       .replaceWith( $(this).html() );
+                               $el
+                                       .text( mw.msg( options.prefix + $el.attr( 'key' ) ) )
+                                       .replaceWith( $el.html() );
                        } )
                        .end()
                .find( '[title-msg]' )
                        .each( function() {
-                               $(this)
-                                       .attr( 'title', mw.msg( options.prefix + $(this).attr( 'title-msg' ) ) )
+                               var $el = $(this);
+                               $el
+                                       .attr( 'title', mw.msg( options.prefix + $el.attr( 'title-msg' ) ) )
                                        .removeAttr( 'title-msg' );
                        } )
                        .end()
                .find( '[alt-msg]' )
                        .each( function() {
-                               $(this)
-                                       .attr( 'alt', mw.msg( options.prefix + $(this).attr( 'alt-msg' ) ) )
+                               var $el = $(this);
+                               $el
+                                       .attr( 'alt', mw.msg( options.prefix + $el.attr( 'alt-msg' ) ) )
                                        .removeAttr( 'alt-msg' );
                        } )
                        .end();