r82752 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r82751‎ | r82752 | r82753 >
Date:23:02, 24 February 2011
Author:krinkle
Status:ok
Tags:
Comment:
caching selector instead of re-creating the jQuery object for 'this' two or three times
Modified paths:
  • /trunk/phase3/resources/jquery/jquery.localize.js (modified) (history)

Diff [purge]

Index: trunk/phase3/resources/jquery/jquery.localize.js
@@ -37,22 +37,24 @@
3838 .find( 'msg,html\\:msg' )
3939 .each( function() {
4040 var $el = $(this);
41 - $(this)
42 - .text( mw.msg( options.prefix + $(this).attr( 'key' ) ) )
43 - .replaceWith( $(this).html() );
 41+ $el
 42+ .text( mw.msg( options.prefix + $el.attr( 'key' ) ) )
 43+ .replaceWith( $el.html() );
4444 } )
4545 .end()
4646 .find( '[title-msg]' )
4747 .each( function() {
48 - $(this)
49 - .attr( 'title', mw.msg( options.prefix + $(this).attr( 'title-msg' ) ) )
 48+ var $el = $(this);
 49+ $el
 50+ .attr( 'title', mw.msg( options.prefix + $el.attr( 'title-msg' ) ) )
5051 .removeAttr( 'title-msg' );
5152 } )
5253 .end()
5354 .find( '[alt-msg]' )
5455 .each( function() {
55 - $(this)
56 - .attr( 'alt', mw.msg( options.prefix + $(this).attr( 'alt-msg' ) ) )
 56+ var $el = $(this);
 57+ $el
 58+ .attr( 'alt', mw.msg( options.prefix + $el.attr( 'alt-msg' ) ) )
5759 .removeAttr( 'alt-msg' );
5860 } )
5961 .end();

Status & tagging log