r44774 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r44773‎ | r44774 | r44775 >
Date:18:16, 18 December 2008
Author:simetrical
Status:ok (Comments)
Tags:
Comment:
(bug 16459) Use native getElementsByClassName

Patch by Derk-Jan Hartman. Seems not to break table sorting in Firefox
3, and he's tested it in other browsers, including IE6. (Of course it
falls back to ordinary JS if the native version is unavailable.)
Modified paths:
  • /trunk/phase3/CREDITS (modified) (history)
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/skins/common/wikibits.js (modified) (history)

Diff [purge]

Index: trunk/phase3/skins/common/wikibits.js
@@ -454,8 +454,19 @@
455455 From http://www.robertnyman.com/2005/11/07/the-ultimate-getelementsbyclassname/
456456 */
457457 function getElementsByClassName(oElm, strTagName, oClassNames){
 458+ var arrReturnElements = new Array();
 459+ if ( typeof( oElm.getElementsByClassName ) == "function" ) {
 460+ /* Use a native implementation where possible FF3, Saf3.2, Opera 9.5 */
 461+ var arrNativeReturn = oElm.getElementsByClassName( oClassNames );
 462+ if ( strTagName == "*" )
 463+ return arrNativeReturn;
 464+ for ( var h=0; h < arrNativeReturn.length; h++ ) {
 465+ if( arrNativeReturn[h].tagName.toLowerCase() == strTagName.toLowerCase() )
 466+ arrReturnElements[arrReturnElements.length] = arrNativeReturn[h];
 467+ }
 468+ return arrReturnElements;
 469+ }
458470 var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
459 - var arrReturnElements = new Array();
460471 var arrRegExpClassNames = new Array();
461472 if(typeof oClassNames == "object"){
462473 for(var i=0; i<oClassNames.length; i++){
Index: trunk/phase3/CREDITS
@@ -18,6 +18,7 @@
1919 * Daniel Kinzler
2020 * Danny B.
2121 * David McCabe
 22+* Derk-Jan Hartman
2223 * Domas Mituzas
2324 * Fran Rogers
2425 * Greg Sabino Mullane
Index: trunk/phase3/RELEASE-NOTES
@@ -233,6 +233,8 @@
234234 * (bug 7492) Rights can now be assigned to specific IP addresses and ranges by
235235 using $wgAutopromote (new defines: APCOND_ISIP and APCOND_IPINRANGE)
236236 * Add a 'change block' link to Special:IPBlockList and Special:Log
 237+* (bug 16459) Use native getElementsByClassName where possible, for better
 238+ performance in modern browsers
237239
238240 === Bug fixes in 1.14 ===
239241

Follow-up revisions

RevisionCommit summaryAuthorDate
r44785Bump $wgStyleVersion per r44774/r44782raymond21:48, 18 December 2008

Comments

#Comment by Brion VIBBER (talk | contribs)   19:11, 23 December 2008

w00t!

Status & tagging log