r82572 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r82571‎ | r82572 | r82573 >
Date:20:36, 21 February 2011
Author:krinkle
Status:ok (Comments)
Tags:
Comment:
Follow-up r73270. Moving the attribute check down to the point where it's for sure not a string or undefined. (caused 'cant call getAttribute member function on non-object el [undefined]'. Also add a check to verify that el is a dom element and not just not indefined
Modified paths:
  • /trunk/phase3/skins/common/wikibits.js (modified) (history)

Diff [purge]

Index: trunk/phase3/skins/common/wikibits.js
@@ -332,16 +332,18 @@
333333 };
334334
335335 window.getInnerText = function( el ) {
336 - if ( el.getAttribute( 'data-sort-value' ) !== null ) {
337 - return el.getAttribute( 'data-sort-value' );
338 - }
339 -
340336 if ( typeof el == 'string' ) {
341337 return el;
342338 }
343339 if ( typeof el == 'undefined' ) {
344340 return el;
345341 }
 342+ // Custom sort value through 'data-sort-value' attribute
 343+ // (no need to prepend hidden text to change sort value)
 344+ if ( el.nodeType && el.getAttribute( 'data-sort-value' ) !== null ) {
 345+ // Make sure it's a valid DOM element (.nodeType) and that the attribute is set (!null)
 346+ return el.getAttribute( 'data-sort-value' );
 347+ }
346348 if ( el.textContent ) {
347349 return el.textContent; // not needed but it is faster
348350 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r826781.17wmf1: MFT r82473, r82572, r82574, r82601, r82608, r82654catrope16:34, 23 February 2011
r85354MFT r82518, r82530, r82538, r82547, r82550, r82565, r82572, r82608, r82696, r...demon18:25, 4 April 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r73270Allow defining sortable value for table cell with data-sort-value....nikerabbit08:28, 18 September 2010

Comments

#Comment by Krinkle (talk | contribs)   20:59, 21 February 2011

This commit fixees bug 27608.

Status & tagging log