From 9502e76d1c681d07fd6f80f30eae2ed9ccdeb829 Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Thu, 27 Jun 2019 16:35:37 +0100 Subject: [PATCH] TOC: Avoid Sizzle selectors Change-Id: I06486234dd42260e696250a702f406eb043d159e --- resources/src/mediawiki.toc/toc.js | 2 +- .../qunit/suites/resources/mediawiki/mediawiki.toc.test.js | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/resources/src/mediawiki.toc/toc.js b/resources/src/mediawiki.toc/toc.js index e5745689ff..c1066f2c51 100644 --- a/resources/src/mediawiki.toc/toc.js +++ b/resources/src/mediawiki.toc/toc.js @@ -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' ); diff --git a/tests/qunit/suites/resources/mediawiki/mediawiki.toc.test.js b/tests/qunit/suites/resources/mediawiki/mediawiki.toc.test.js index 74fd743bb5..6dcdb445fe 100644 --- a/tests/qunit/suites/resources/mediawiki/mediawiki.toc.test.js +++ b/tests/qunit/suites/resources/mediawiki/mediawiki.toc.test.js @@ -21,17 +21,16 @@ $( '#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(); } ); -- 2.20.1