From 3863dd231f2fdda95c28193a05e550167f023b5f Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Thu, 17 Aug 2017 18:51:17 -0700 Subject: [PATCH] Remove deprecated jquery.mwExtension module * Deprecated since MediaWiki 1.26. * Not used anywhere in Wikimedia Git. * Grafana mw-js-deprecate dashboard shows < 1 hit per day on average for any of the jquery.mwExtension properties, during the past 3 weeks. Most days 0, some days 18 individual hits. By comparison, legacy wikibits before we removed it in May 2017 was down to about 6,000/24h (combined), so removal is quite overdue. Change-Id: Ib66d1844b4fb8d7185b0e6607b9f98c1be632bb5 --- RELEASE-NOTES-1.30 | 1 + resources/Resources.php | 4 - resources/src/jquery/jquery.mwExtension.js | 128 ------------------ tests/qunit/QUnitTestResources.php | 2 - .../jquery/jquery.mwExtension.test.js | 64 --------- 5 files changed, 1 insertion(+), 198 deletions(-) delete mode 100644 resources/src/jquery/jquery.mwExtension.js delete mode 100644 tests/qunit/suites/resources/jquery/jquery.mwExtension.test.js diff --git a/RELEASE-NOTES-1.30 b/RELEASE-NOTES-1.30 index 9474f21fd2..1ab646957b 100644 --- a/RELEASE-NOTES-1.30 +++ b/RELEASE-NOTES-1.30 @@ -168,6 +168,7 @@ changes to languages because of Phabricator reports. * WikiImporter now requires the second parameter to be an instance of the Config, class. Prior to that, the Config parameter was optional (a behavior deprecated in 1.25). +* Removed 'jquery.mwExtension' module. (deprecated since 1.26) == Compatibility == MediaWiki 1.30 requires PHP 5.5.9 or later. There is experimental support for diff --git a/resources/Resources.php b/resources/Resources.php index 09bd4dc762..5aa166d9b7 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -301,10 +301,6 @@ return [ 'scripts' => 'resources/src/jquery/jquery.mw-jump.js', 'targets' => [ 'desktop', 'mobile' ], ], - 'jquery.mwExtension' => [ - 'scripts' => 'resources/src/jquery/jquery.mwExtension.js', - 'targets' => [ 'desktop', 'mobile' ], - ], 'jquery.placeholder' => [ 'deprecated' => 'Use of "jquery.placeholder" is deprecated since MediaWiki 1.29.0', diff --git a/resources/src/jquery/jquery.mwExtension.js b/resources/src/jquery/jquery.mwExtension.js deleted file mode 100644 index 9d970ed274..0000000000 --- a/resources/src/jquery/jquery.mwExtension.js +++ /dev/null @@ -1,128 +0,0 @@ -/* - * JavaScript backwards-compatibility alternatives and other convenience functions - * - * @deprecated since 1.26 Dated collection of miscellaneous utilities. Methods are - * either trivially inline, obsolete, or have a better place elsewhere. - */ -( function ( $, mw ) { - $.each( { - trimLeft: function ( str ) { - return str === null ? '' : str.toString().replace( /^\s+/, '' ); - }, - trimRight: function ( str ) { - return str === null ? - '' : str.toString().replace( /\s+$/, '' ); - }, - ucFirst: function ( str ) { - return str.charAt( 0 ).toUpperCase() + str.slice( 1 ); - }, - isDomElement: function ( el ) { - return !!el && !!el.nodeType; - }, - isEmpty: function ( v ) { - var key; - if ( - v === '' || v === 0 || v === '0' || v === null || v === false || v === undefined - ) { - return true; - } - // the for-loop could potentially contain prototypes - // to avoid that we check its length first - if ( v.length === 0 ) { - return true; - } - if ( typeof v === 'object' ) { - for ( key in v ) { - return false; - } - return true; - } - return false; - }, - compareArray: function ( arrThis, arrAgainst ) { - var i; - if ( arrThis.length !== arrAgainst.length ) { - return false; - } - for ( i = 0; i < arrThis.length; i++ ) { - if ( Array.isArray( arrThis[ i ] ) ) { - if ( !$.compareArray( arrThis[ i ], arrAgainst[ i ] ) ) { - return false; - } - } else if ( arrThis[ i ] !== arrAgainst[ i ] ) { - return false; - } - } - return true; - }, - compareObject: function ( objectA, objectB ) { - var prop, type; - - // Do a simple check if the types match - if ( typeof objectA === typeof objectB ) { - - // Only loop over the contents if it really is an object - if ( typeof objectA === 'object' ) { - // If they are aliases of the same object (ie. mw and mediaWiki) return now - if ( objectA === objectB ) { - return true; - } else { - // Iterate over each property - for ( prop in objectA ) { - // Check if this property is also present in the other object - if ( prop in objectB ) { - // Compare the types of the properties - type = typeof objectA[ prop ]; - if ( type === typeof objectB[ prop ] ) { - // Recursively check objects inside this one - switch ( type ) { - case 'object' : - if ( !$.compareObject( objectA[ prop ], objectB[ prop ] ) ) { - return false; - } - break; - case 'function' : - // Functions need to be strings to compare them properly - if ( objectA[ prop ].toString() !== objectB[ prop ].toString() ) { - return false; - } - break; - default: - // Strings, numbers - if ( objectA[ prop ] !== objectB[ prop ] ) { - return false; - } - break; - } - } else { - return false; - } - } else { - return false; - } - } - // Check for properties in B but not in A - // This is about 15% faster (tested in Safari 5 and Firefox 3.6) - // ...than incrementing a count variable in the above and below loops - // See also: https://www.mediawiki.org/wiki/ResourceLoader/Default_modules/compareObject_test#Results - for ( prop in objectB ) { - if ( !( prop in objectA ) ) { - return false; - } - } - } - } - } else { - return false; - } - return true; - } - }, function ( key, value ) { - mw.log.deprecate( $, key, value, null, '$.' + key ); - } ); - - mw.log.deprecate( $, 'escapeRE', function ( str ) { - return str.replace( /([\\{}()|.?*+\-^$\[\]])/g, '\\$1' ); // eslint-disable-line no-useless-escape - }, 'Use mediawiki.RegExp instead.', '$.escapeRE' ); - -}( jQuery, mediaWiki ) ); diff --git a/tests/qunit/QUnitTestResources.php b/tests/qunit/QUnitTestResources.php index ee3cd5bbfb..7367560e90 100644 --- a/tests/qunit/QUnitTestResources.php +++ b/tests/qunit/QUnitTestResources.php @@ -56,7 +56,6 @@ return [ 'tests/qunit/suites/resources/jquery/jquery.highlightText.test.js', 'tests/qunit/suites/resources/jquery/jquery.localize.test.js', 'tests/qunit/suites/resources/jquery/jquery.makeCollapsible.test.js', - 'tests/qunit/suites/resources/jquery/jquery.mwExtension.test.js', 'tests/qunit/suites/resources/jquery/jquery.tabIndex.test.js', 'tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js', 'tests/qunit/suites/resources/jquery/jquery.tablesorter.parsers.test.js', @@ -112,7 +111,6 @@ return [ 'jquery.highlightText', 'jquery.localize', 'jquery.makeCollapsible', - 'jquery.mwExtension', 'jquery.tabIndex', 'jquery.tablesorter', 'jquery.textSelection', diff --git a/tests/qunit/suites/resources/jquery/jquery.mwExtension.test.js b/tests/qunit/suites/resources/jquery/jquery.mwExtension.test.js deleted file mode 100644 index aeda51651f..0000000000 --- a/tests/qunit/suites/resources/jquery/jquery.mwExtension.test.js +++ /dev/null @@ -1,64 +0,0 @@ -( function ( $ ) { - QUnit.module( 'jquery.mwExtension', QUnit.newMwEnvironment( { - // This entire module is deprecated. - // Surpress deprecation warnings in test output. - setup: function () { - this.suppressWarnings(); - }, - teardown: function () { - this.restoreWarnings(); - } - } ) ); - - QUnit.test( 'String functions', function ( assert ) { - assert.equal( $.trimLeft( ' foo bar ' ), 'foo bar ', 'trimLeft' ); - assert.equal( $.trimRight( ' foo bar ' ), ' foo bar', 'trimRight' ); - assert.equal( $.ucFirst( 'foo' ), 'Foo', 'ucFirst' ); - - assert.equal( $.escapeRE( '