mediawiki.special.recentchanges: Use module.exports instead of mw.special
authorTimo Tijhof <krinklemail@gmail.com>
Thu, 26 May 2016 17:35:28 +0000 (18:35 +0100)
committerJforrester <jforrester@wikimedia.org>
Thu, 26 May 2016 17:45:39 +0000 (17:45 +0000)
This isn't generally used as a public method. The only reason it's exposed is
for an integration test to access it.

This commit and others prepare for removal of the 'mediawiki.special.js' file.
This script does nothing other than create "mw.special = {};". While that init
pattern is common in extensions and not wrong, 'mediawiki.special' violates
T92459 due to having styles. Given there's only script uses of it, it's easiest
to remove it in favour of the new module export pattern.

Change-Id: I2e78828828601e1160550efe02c07172ac32e985

resources/Resources.php
resources/src/mediawiki.special/mediawiki.special.recentchanges.js
tests/qunit/suites/resources/mediawiki.special/mediawiki.special.recentchanges.test.js

index bacf1e6..4d5173f 100644 (file)
@@ -1880,7 +1880,6 @@ return [
        ],
        'mediawiki.special.recentchanges' => [
                'scripts' => 'resources/src/mediawiki.special/mediawiki.special.recentchanges.js',
-               'dependencies' => 'mediawiki.special',
                'position' => 'top',
        ],
        'mediawiki.special.search' => [
index d43b62b..bdd45bc 100644 (file)
@@ -34,6 +34,6 @@
 
        $( rc.init );
 
-       mw.special.recentchanges = rc;
+       module.exports = rc;
 
 }( mediaWiki, jQuery ) );
index ee854ae..edc2716 100644 (file)
@@ -4,7 +4,8 @@
        // TODO: verify checkboxes == [ 'nsassociated', 'nsinvert' ]
 
        QUnit.test( '"all" namespace disable checkboxes', 8, function ( assert ) {
-               var selectHtml, $env, $options;
+               var selectHtml, $env, $options,
+                       rc = require( 'mediawiki.special.recentchanges' );
 
                // from Special:Recentchanges
                selectHtml = '<select id="namespace" name="namespace" class="namespaceselector">'
@@ -32,7 +33,7 @@
                assert.strictEqual( $( '#nsassociated' ).prop( 'disabled' ), false );
 
                // Initiate the recentchanges module
-               mw.special.recentchanges.init();
+               rc.init();
 
                // By default
                assert.strictEqual( $( '#nsinvert' ).prop( 'disabled' ), true );