TOC: Avoid Sizzle selectors
authorEd Sanders <esanders@wikimedia.org>
Thu, 27 Jun 2019 15:35:37 +0000 (16:35 +0100)
committerEd Sanders <esanders@wikimedia.org>
Thu, 27 Jun 2019 15:35:37 +0000 (16:35 +0100)
Change-Id: I06486234dd42260e696250a702f406eb043d159e

resources/src/mediawiki.toc/toc.js
tests/qunit/suites/resources/mediawiki/mediawiki.toc.test.js

index e574568..c1066f2 100644 (file)
@@ -13,7 +13,7 @@
 
                        // Hide/show the table of contents element
                        function toggleToc() {
-                               if ( $tocList.is( ':hidden' ) ) {
+                               if ( $this.hasClass( 'tochidden' ) ) {
                                        // FIXME: Use CSS transitions
                                        // eslint-disable-next-line no-jquery/no-slide
                                        $tocList.slideDown( 'fast' );
index 74fd743..6dcdb44 100644 (file)
                $( '#qunit-fixture' ).append( $toc );
                mw.hook( 'wikipage.content' ).fire( $( '#qunit-fixture' ) );
 
-               $tocList = $toc.find( 'ul:first' );
+               $tocList = $toc.find( 'ul' ).first();
                $toggleLink = $toc.find( '.togglelink' );
 
                assert.strictEqual( $toggleLink.length, 1, 'Toggle link is added to the table of contents' );
 
-               assert.strictEqual( $tocList.is( ':hidden' ), false, 'The table of contents is now visible' );
+               assert.strictEqual( $toc.hasClass( 'tochidden' ), false, 'The table of contents is now visible' );
 
                $toggleLink.trigger( 'click' );
                return $tocList.promise().then( function () {
-                       assert.strictEqual( $tocList.is( ':hidden' ), true, 'The table of contents is now hidden' );
-
+                       assert.strictEqual( $toc.hasClass( 'tochidden' ), true, 'The table of contents is now hidden' );
                        $toggleLink.trigger( 'click' );
                        return $tocList.promise();
                } );