From 76935df945b43fec9dc2604b10ab28fae5dfc630 Mon Sep 17 00:00:00 2001 From: Krinkle Date: Thu, 24 Feb 2011 23:02:56 +0000 Subject: [PATCH] caching selector instead of re-creating the jQuery object for 'this' two or three times --- resources/jquery/jquery.localize.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/resources/jquery/jquery.localize.js b/resources/jquery/jquery.localize.js index 27d6584758..15e0164955 100644 --- a/resources/jquery/jquery.localize.js +++ b/resources/jquery/jquery.localize.js @@ -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(); -- 2.20.1