HTMLForm: Use 'mw-htmlform' CSS class
authorBartosz Dziewoński <matma.rex@gmail.com>
Fri, 2 Dec 2016 19:19:07 +0000 (20:19 +0100)
committerLegoktm <legoktm@member.fsf.org>
Sun, 18 Dec 2016 12:59:05 +0000 (12:59 +0000)
Makes it easy to identify all HTMLForms on a page.

Change-Id: I5b9494fc925ac953c14b358331acddfe80c2661d

includes/htmlform/HTMLForm.php
includes/htmlform/OOUIHTMLForm.php
includes/htmlform/VFormHTMLForm.php
resources/src/mediawiki/htmlform/styles.css
tests/phpunit/includes/specials/SpecialEditWatchlistTest.php

index 71ccaa3..5c5a9a7 100644 (file)
@@ -1047,6 +1047,7 @@ class HTMLForm extends ContextSource {
                        : 'application/x-www-form-urlencoded';
                # Attributes
                $attribs = [
+                       'class' => 'mw-htmlform',
                        'action' => $this->getAction(),
                        'method' => $this->getMethod(),
                        'enctype' => $encType,
@@ -1079,7 +1080,7 @@ class HTMLForm extends ContextSource {
 
                return Html::rawElement(
                        'form',
-                       $this->getFormAttributes() + [ 'class' => 'visualClear' ],
+                       $this->getFormAttributes(),
                        $html
                );
        }
index 46b570d..54bdf04 100644 (file)
@@ -275,7 +275,7 @@ class OOUIHTMLForm extends HTMLForm {
 
        public function wrapForm( $html ) {
                $form = new OOUI\FormLayout( $this->getFormAttributes() + [
-                       'classes' => [ 'mw-htmlform-ooui' ],
+                       'classes' => [ 'mw-htmlform', 'mw-htmlform-ooui' ],
                        'content' => new OOUI\HtmlSnippet( $html ),
                ] );
 
index 5d9f7a0..325526b 100644 (file)
@@ -67,7 +67,7 @@ class VFormHTMLForm extends HTMLForm {
 
        protected function getFormAttributes() {
                $attribs = parent::getFormAttributes();
-               $attribs['class'] = [ 'mw-ui-vform', 'mw-ui-container', 'visualClear' ];
+               $attribs['class'] = [ 'mw-htmlform', 'mw-ui-vform', 'mw-ui-container' ];
                return $attribs;
        }
 
index 1603130..1b9d2fb 100644 (file)
@@ -1,5 +1,9 @@
 /* HTMLForm styles */
 
+.mw-htmlform {
+       clear: both;
+}
+
 table.mw-htmlform-nolabel td.mw-label {
        display: none;
 }
index cd84d79..ab3ac55 100644 (file)
@@ -33,7 +33,7 @@ class SpecialEditWatchlistTest extends SpecialPageTestBase {
                $user = new TestUser( __METHOD__ );
                list( $html, ) = $this->executeSpecialPage( 'clear', null, 'qqx', $user->getUser() );
                $this->assertRegExp(
-                       '/<form action=".*?Special:EditWatchlist\/clear" method="post" class="visualClear">/',
+                       '/<form class="mw-htmlform" action=".*?Special:EditWatchlist\/clear" method="post">/',
                        $html
                );
        }