mediawiki.Title: Fix doc reference error
authorTimo Tijhof <krinklemail@gmail.com>
Tue, 15 Oct 2013 20:09:54 +0000 (22:09 +0200)
committerTimo Tijhof <krinklemail@gmail.com>
Tue, 15 Oct 2013 20:09:54 +0000 (22:09 +0200)
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

resources/mediawiki/mediawiki.Title.js

index 346ab33..b236019 100644 (file)
         *     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,
 
                        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 );