Jdlrobson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/319066

Change subject: Section blocks should have id attribute
......................................................................

Section blocks should have id attribute

An id attribute allows JavaScript to access the DOMElement
representing the section body via getElementById. Given the wider
support for this method in comparison to getElementsByClassName
and the fact that classes are not meant to be unique per element
the existing usages of mf-section- classes are discouraged.

Change-Id: I53cfd1f593405d73ff1e0c0630f3a05803a9d1c2
---
M includes/MobileFormatter.php
M tests/phpunit/MobileFormatterTest.php
2 files changed, 5 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/66/319066/1

diff --git a/includes/MobileFormatter.php b/includes/MobileFormatter.php
index 6bb39d6..e83b9f3 100644
--- a/includes/MobileFormatter.php
+++ b/includes/MobileFormatter.php
@@ -532,7 +532,10 @@
 
                $sectionNumber = 0;
                $sectionBody = $doc->createElement( 'div' );
+               // FIXME: The class `/mf\-section\-[0-9]+/` is kept for caching 
reasons
+               // but given class is unique usage is discouraged. [T126825]
                $sectionBody->setAttribute( 'class', 'mf-section-' . 
$sectionNumber );
+               $sectionBody->setAttribute( 'id', 'mf-section-' . 
$sectionNumber );
 
                // Mark the top level headings which will become collapsible 
soon.
                foreach ( $headings as $heading ) {
diff --git a/tests/phpunit/MobileFormatterTest.php 
b/tests/phpunit/MobileFormatterTest.php
index 52a97e8..dab1d7d 100644
--- a/tests/phpunit/MobileFormatterTest.php
+++ b/tests/phpunit/MobileFormatterTest.php
@@ -31,7 +31,8 @@
         */
        private function makeSectionHtml( $sectionNumber, $contentHtml='', 
$isReferenceSection=false ) {
                $attrs = $isReferenceSection ? ' data-is-reference-section="1"' 
: '';
-               return "<div 
class=\"mf-section-$sectionNumber\"$attrs>$contentHtml</div>";
+               return "<div class=\"mf-section-$sectionNumber\" 
id=\"mf-section-$sectionNumber\""
+                       . "$attrs>$contentHtml</div>";
        }
 
        /**

-- 
To view, visit https://gerrit.wikimedia.org/r/319066
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I53cfd1f593405d73ff1e0c0630f3a05803a9d1c2
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to