From: Timo Tijhof Date: Tue, 15 Oct 2013 20:09:54 +0000 (+0200) Subject: mediawiki.Title: Fix doc reference error X-Git-Tag: 1.31.0-rc.0~18508 X-Git-Url: https://git.cyclocoop.org/%7B%7B%20url_for%28?a=commitdiff_plain;h=4362d8f15103658cd8df4fae3a4691e9ae7e7bb6;p=lhc%2Fweb%2Fwiklou.git mediawiki.Title: Fix doc reference error Follows-up 165373d which introduced a reference to a browser global not in our index (causing a jsduck error). Unless we're using an element that has special DOM methods I don't think it's worth adding element subclasses to the doc index. We generally just use HTMLElement so changed it to that. Also made a minor optimisation in merging the img/src assignments by using .prop( 'src' ) and .src directly. And while at it also reduced it to direct access with [0] instead of .get(). Change-Id: I3a521eda0aeeb7847a96d474316d1d5e6e8917d1 --- diff --git a/resources/mediawiki/mediawiki.Title.js b/resources/mediawiki/mediawiki.Title.js index 346ab33e9c..b236019663 100644 --- a/resources/mediawiki/mediawiki.Title.js +++ b/resources/mediawiki/mediawiki.Title.js @@ -304,8 +304,8 @@ * var title = mw.Title.newFromImg( $( 'img:first' ) ); * * @static - * @param {HTMLImageElement|jQuery} img The image to use as a base. - * @return {mw.Title|null} The file title - null if unsuccessful. + * @param {HTMLElement|jQuery} img The image to use as a base + * @return {mw.Title|null} The file title or null if unsuccessful */ Title.newFromImg = function ( img ) { var matches, i, regex, src, decodedSrc, @@ -329,9 +329,7 @@ recount = regexes.length; - img = img.jquery ? img.get( 0 ) : img; - - src = img.src; + src = img.jquery ? img[0].src : img.src; matches = src.match( thumbPhpRegex );