Use .toc instead of #toc as selector for TOC
authorFomafix <fomafix@googlemail.com>
Sat, 15 Apr 2017 06:45:25 +0000 (08:45 +0200)
committerKrinkle <krinklemail@gmail.com>
Tue, 18 Apr 2017 01:26:26 +0000 (01:26 +0000)
Since 1bf5a652 multiple TOCs are supported.

In CSS the selector #toc is kept for backward compatibility for uses in the
content.

Change-Id: I07036c0d5782420fc127781a15c675fc7e6fafaf

resources/src/mediawiki.legacy/commonPrint.css
resources/src/mediawiki/mediawiki.toc.print.css
tests/qunit/suites/resources/mediawiki/mediawiki.toc.test.js

index e3e80d8..b4418e5 100644 (file)
@@ -121,7 +121,8 @@ img {
        margin: 0 !important; /* stylelint-disable-line declaration-no-important */
 }
 
-#toc {
+#toc,
+.toc {
        background-color: #f9f9f9;
        border: 1pt solid #aaa;
        padding: 5px;
index da2c08f..5f6eb25 100644 (file)
@@ -1,4 +1,5 @@
 #toc.tochidden,
+.toc.tochidden,
 .toctoggle {
        display: none;
 }
index 70a7e35..8786993 100644 (file)
@@ -7,9 +7,9 @@
        } ) );
 
        QUnit.asyncTest( 'toggleToc', function ( assert ) {
-               var tocHtml, $toggleLink, $tocList;
+               var tocHtml, $toc, $toggleLink, $tocList;
 
-               assert.strictEqual( $( '#toc' ).length, 0, 'There is no table of contents on the page at the beginning' );
+               assert.strictEqual( $( '.toc' ).length, 0, 'There is no table of contents on the page at the beginning' );
 
                tocHtml = '<div id="toc" class="toc">' +
                        '<div id="toctitle" class="toctitle">' +
                        '</div>' +
                        '<ul><li></li></ul>' +
                        '</div>';
-               $( tocHtml ).appendTo( '#qunit-fixture' );
+               $toc = $( tocHtml );
+               $( '#qunit-fixture' ).append( $toc );
                mw.hook( 'wikipage.content' ).fire( $( '#qunit-fixture' ) );
 
-               $tocList = $( '#toc ul:first' );
-               $toggleLink = $( '#toc .togglelink' );
+               $tocList = $toc.find( 'ul:first' );
+               $toggleLink = $toc.find( '.togglelink' );
 
                assert.strictEqual( $toggleLink.length, 1, 'Toggle link is added to the table of contents' );