From cd253e0143f685499a79f737d1106666b78a86e6 Mon Sep 17 00:00:00 2001 From: Krinkle Date: Mon, 21 Feb 2011 20:36:07 +0000 Subject: [PATCH] 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 --- skins/common/wikibits.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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 } -- 2.20.1