diff -u b/core/misc/form.js b/core/misc/form.js --- b/core/misc/form.js +++ b/core/misc/form.js @@ -196,13 +196,14 @@ Drupal.behaviors.fillUserInfoFromBrowser = { attach: function (context, settings) { var userInfo = ['name', 'mail', 'homepage']; - var $forms = $('form.user-info-from-browser').once('user-info-from-browser'); + var $forms = $('[user-info-from-browser]').once('user-info-from-browser'); if ($forms.length) { var browserData; userInfo.map(function (info) { var $element = $forms.find('[name=' + info + ']'); browserData = localStorage.getItem('Drupal.visitor.' + info); - if ($element.length && ($element.val() === '' || ($element.attr('data-drupal-default-value') === $element.val())) && browserData) { + var emptyOrDefault = ($element.val() === '' || ($element.attr('data-drupal-default-value') === $element.val())); + if ($element.length && emptyOrDefault && browserData) { $element.val(browserData); } }); diff -u b/core/modules/comment/lib/Drupal/comment/CommentFormController.php b/core/modules/comment/lib/Drupal/comment/CommentFormController.php --- b/core/modules/comment/lib/Drupal/comment/CommentFormController.php +++ b/core/modules/comment/lib/Drupal/comment/CommentFormController.php @@ -100,7 +100,7 @@ if (!$this->currentUser->isAuthenticated() && $anonymous_contact != COMMENT_ANONYMOUS_MAYNOT_CONTACT) { $form['#attached']['library'][] = 'core/drupal.form'; - $form['#attributes']['class'][] = 'user-info-from-browser'; + $form['#attributes']['user-info-from-browser'] = TRUE; } // If not replying to a comment, use our dedicated page callback for new diff -u b/core/modules/contact/lib/Drupal/contact/MessageFormController.php b/core/modules/contact/lib/Drupal/contact/MessageFormController.php --- b/core/modules/contact/lib/Drupal/contact/MessageFormController.php +++ b/core/modules/contact/lib/Drupal/contact/MessageFormController.php @@ -54,7 +54,7 @@ ); if ($user->isAnonymous()) { $form['#attached']['library'][] = 'core/drupal.form'; - $form['#attributes']['class'][] = 'user-info-from-browser'; + $form['#attributes']['user-info-from-browser'] = TRUE; } // Do not allow authenticated users to alter the name or e-mail values to // prevent the impersonation of other users. diff -u b/core/modules/user/lib/Drupal/user/RegisterFormController.php b/core/modules/user/lib/Drupal/user/RegisterFormController.php --- b/core/modules/user/lib/Drupal/user/RegisterFormController.php +++ b/core/modules/user/lib/Drupal/user/RegisterFormController.php @@ -44,7 +44,7 @@ return new RedirectResponse(url('user/' . \Drupal::currentUser()->id(), array('absolute' => TRUE))); } - $form['#attributes']['class'][] = 'user-info-from-browser'; + $form['#attributes']['user-info-from-browser'] = TRUE; // Start with the default user account fields. $form = parent::form($form, $form_state, $account);