mediawiki.Upload: Allow passing mw.Api objects, not just configs
authorBartosz Dziewoński <matma.rex@gmail.com>
Tue, 18 Aug 2015 16:14:23 +0000 (18:14 +0200)
committerBartosz Dziewoński <matma.rex@gmail.com>
Thu, 20 Aug 2015 15:46:02 +0000 (15:46 +0000)
This way we'll be able to use a mw.ForeignApi here
(being introduced in Ic20b9682d28633baa87d22e6e9fb71ce507da58d).

Change-Id: Ie49d7dad5abfe567f9b9c7396f8e132875568fd3

resources/src/mediawiki/mediawiki.Upload.js

index 551aa9d..58c66c1 100644 (file)
         *     } );
         *
         * @constructor
-        * @param {Object} apiconfig Passed to the constructor of mw.Api.
+        * @param {Object|mw.Api} [apiconfig] A mw.Api object (or subclass), or configuration
+        *     to pass to the constructor of mw.Api.
         */
        function Upload( apiconfig ) {
-               this.api = new mw.Api( apiconfig );
+               this.api = ( apiconfig instanceof mw.Api ) ? apiconfig : new mw.Api( apiconfig );
 
                this.watchlist = false;
                this.text = '';