Bartosz Dziewoński has uploaded a new change for review.

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


Change subject: Simplify boolean attribute handling for Html::input in templates
......................................................................

Simplify boolean attribute handling for Html::input in templates

The Html class supports this handy shorthand.

Change-Id: Ie34790fa650c7ecad02c2d91130bf0db9172ea3f
---
M includes/templates/Usercreate.php
M includes/templates/Userlogin.php
2 files changed, 9 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/55/90155/1

diff --git a/includes/templates/Usercreate.php 
b/includes/templates/Usercreate.php
index 7a4b9f2..6dd5f35 100644
--- a/includes/templates/Usercreate.php
+++ b/includes/templates/Usercreate.php
@@ -158,9 +158,10 @@
                                                        'id' => 'wpEmail',
                                                        'tabindex' => '6',
                                                        'size' => '20',
+                                                       'required' => 
!!$this->data['emailrequired'],
                                                        'placeholder' => 
$this->getMsg( $this->data['loggedin'] ?
                                                                
'createacct-another-email-ph' : 'createacct-email-ph' )->text()
-                                               ) + ( 
$this->data['emailrequired'] ? array() : array( 'required' => '' ) ) );
+                                               ) );
                                        ?>
                                <?php } ?>
                        </div>
diff --git a/includes/templates/Userlogin.php b/includes/templates/Userlogin.php
index f5ae353..9ab353d 100644
--- a/includes/templates/Userlogin.php
+++ b/includes/templates/Userlogin.php
@@ -69,10 +69,6 @@
                                </label>
                                <?php
                                $extraAttrs = array();
-                               // Set focus to this field if it's blank.
-                               if ( !$this->data['name'] ) {
-                                       $extraAttrs['autofocus'] = '';
-                               }
                                echo Html::input( 'wpName', 
$this->data['name'], 'text', array(
                                        'class' => 'loginText',
                                        'id' => 'wpName1',
@@ -80,9 +76,11 @@
                                        'size' => '20',
                                        // 'required' is blacklisted for now in 
Html.php due to browser issues.
                                        // Keeping here in case that changes.
-                                       'required',
+                                       'required' => true,
+                                       // Set focus to this field if it's 
blank.
+                                       'autofocus' => !$this->data['name'],
                                        'placeholder' => $this->getMsg( 
'userlogin-yourname-ph' )->text()
-                               ) + $extraAttrs );
+                               ) );
                                ?>
                        </div>
 
@@ -101,18 +99,15 @@
                                        ?>
                                </label>
                                <?php
-                               $extraAttrs = array();
-                               // Set focus to this field if username is 
filled in.
-                               if ( $this->data['name'] ) {
-                                       $extraAttrs['autofocus'] = '';
-                               }
                                echo Html::input( 'wpPassword', null, 
'password', array(
                                        'class' => 'loginPassword',
                                        'id' => 'wpPassword1',
                                        'tabindex' => '2',
                                        'size' => '20',
+                                       // Set focus to this field if username 
is filled in.
+                                       'autofocus' => !!$this->data['name'],
                                        'placeholder' => $this->getMsg( 
'userlogin-yourpassword-ph' )->text()
-                               ) + $extraAttrs );
+                               ) );
                                ?>
                        </div>
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie34790fa650c7ecad02c2d91130bf0db9172ea3f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Bartosz Dziewoński <[email protected]>

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

Reply via email to