From: Krinkle Date: Mon, 21 Feb 2011 20:36:07 +0000 (+0000) Subject: Follow-up r73270. Moving the attribute check down to the point where it's for sure... X-Git-Tag: 1.31.0-rc.0~31839 X-Git-Url: http://git.cyclocoop.org/%24action?a=commitdiff_plain;h=cd253e0143f685499a79f737d1106666b78a86e6;p=lhc%2Fweb%2Fwiklou.git 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 --- diff --git a/skins/common/wikibits.js b/skins/common/wikibits.js index c70556e278..b862f5c88a 100644 --- a/skins/common/wikibits.js +++ b/skins/common/wikibits.js @@ -332,16 +332,18 @@ window.addPortletLink = function( portlet, href, text, id, tooltip, accesskey, n }; window.getInnerText = function( el ) { - if ( el.getAttribute( 'data-sort-value' ) !== null ) { - return el.getAttribute( 'data-sort-value' ); - } - if ( typeof el == 'string' ) { return el; } if ( typeof el == 'undefined' ) { return el; } + // Custom sort value through 'data-sort-value' attribute + // (no need to prepend hidden text to change sort value) + if ( el.nodeType && el.getAttribute( 'data-sort-value' ) !== null ) { + // Make sure it's a valid DOM element (.nodeType) and that the attribute is set (!null) + return el.getAttribute( 'data-sort-value' ); + } if ( el.textContent ) { return el.textContent; // not needed but it is faster }