diff -u b/core/lib/Drupal/Core/Render/Element/PasswordReveal.php b/core/lib/Drupal/Core/Render/Element/PasswordReveal.php --- b/core/lib/Drupal/Core/Render/Element/PasswordReveal.php +++ b/core/lib/Drupal/Core/Render/Element/PasswordReveal.php @@ -47,6 +47,7 @@ $element['#attributes']['class'][] = 'js-password-field'; $element['#attached']['library'][] = 'core/drupal.revealpass'; $element['#attributes']['data-drupal-revealpass'] = TRUE; + $element['#attributes']['data-drupal-password-strength'] = TRUE; return $element; } diff -u b/core/misc/revealpass.js b/core/misc/revealpass.js --- b/core/misc/revealpass.js +++ b/core/misc/revealpass.js @@ -31,6 +31,19 @@ } /** + * Create reveal button and bind event. + * + * @param {number} index + * @param {HTMLElement} element + */ + function revealLink(index, element) { + var $trigger = $(''); + + $trigger.on('click', {password: element}, revealClickHandle); + $trigger.insertAfter(element); + } + + /** * Initialize reveal links. * * @type {Drupal~behavior} @@ -39,12 +52,7 @@ attach: function (context) { $(context).find('input[type=password][data-drupal-revealpass]') .once('revealpass') - .each(function (index, element) { - var $trigger = $(''); - - $trigger.on('click', {password: element}, revealClickHandle); - $trigger.insertAfter(element); - }); + .each(revealLink); } }; diff -u b/core/modules/user/user.js b/core/modules/user/user.js --- b/core/modules/user/user.js +++ b/core/modules/user/user.js @@ -31,20 +31,15 @@ // Add identifying class to password element parent. $passwordInputParent.addClass('password-parent'); - var passwordSelector = 'js-password-field'; - // If there is a password confirm field use that. - if ($(context).find('input.js-password-confirm').length) { - passwordSelector = 'js-password-confirm'; - } // Add the password confirmation layer. $passwordInputParentWrapper - .find('input.' + passwordSelector) + .find('input[data-drupal-password-strength]') .parent() .append('
' + translate.confirmTitle + '
') .addClass('confirm-parent'); - var $confirmInput = $passwordInputParentWrapper.find('input.' + passwordSelector); - var $confirmResult = $passwordInputParentWrapper.find('div.' + passwordSelector); + var $confirmInput = $passwordInputParentWrapper.find('input[data-drupal-password-strength]'); + var $confirmResult = $passwordInputParentWrapper.find('div.js-password-confirm'); var $confirmChild = $confirmResult.find('span'); // If the password strength indicator is enabled, add its markup. only in patch2: unchanged: --- a/core/lib/Drupal/Core/Render/Element/PasswordConfirm.php +++ b/core/lib/Drupal/Core/Render/Element/PasswordConfirm.php @@ -83,7 +83,10 @@ public static function processPasswordConfirm(&$element, FormStateInterface $for '#title' => t('Confirm password'), '#value' => empty($element['#value']) ? NULL : $element['#value']['pass2'], '#required' => $element['#required'], - '#attributes' => array('class' => array('password-confirm', 'js-password-confirm')), + '#attributes' => array( + 'class' => array('password-confirm', 'js-password-confirm'), + 'data-drupal-password-strength' => TRUE, + ), '#error_no_message' => TRUE, ); $element['#element_validate'] = array(array(get_called_class(), 'validatePasswordConfirm'));