Support from Acquia helps fund testing for Drupal Acquia logo

Comments

nod_’s picture

performance sensitive script, see if it can be made better.

oxyc’s picture

FileSize
10.14 KB

Here's an initial cleanup patch

oxyc’s picture

Status: Active » Needs review
oxyc’s picture

FileSize
10.14 KB

Had a typo on keyup.

oxyc’s picture

Status: Needs review » Needs work
+++ b/core/modules/user/user.permissions.jsundefined
@@ -35,16 +35,15 @@ Drupal.behaviors.permissions = {
+      $table.find('input[type=checkbox]')
+        .not('.rid-anonymous, .rid-authenticated')
+        .addClass('real-checkbox').each(function () {
+          $dummy.clone().insertAfter(this);

This could probably be further simplified into:

      $table.find('input[type=checkbox]')
        .not('.rid-anonymous, .rid-authenticated')
        .addClass('real-checkbox')
        .after($dummy);

----

+++ b/core/modules/user/user.permissions.jsundefined
@@ -35,16 +35,15 @@ Drupal.behaviors.permissions = {
+      $table.find('input[type=checkbox].rid-authenticated').each(self.toggle);

This is probably the most intensive operation but I dont really see a way to optimize it.

oxyc’s picture

Status: Needs work » Needs review
FileSize
10.81 KB

I changed the .each into a simple .after()

nod_’s picture

Status: Needs review » Needs work

user.js:

Can you make the passwordCheck, passwordCheckMatch functions into named functions?


    var $checkbox = $('#edit-instance-settings-user-register-form');

    if ($checkbox.length) {
      $('#edit-instance-required').once('user-register-form-checkbox')

I'd rather have that as:

    var $checkbox = $('#edit-instance-settings-user-register-form');
    var $instance =  $('#edit-instance-required').once('user-register-form-checkbox');

    if ($checkbox.length && $instance.length) {

user.permissions.js:

can you separate the .once() call and the function in there? there is no need for this closure. Have a look at other core scripts to see what I mean (yay! can finally say that with some confidence :).

Beside that it's all good :) thanks a lot!

oxyc’s picture

FileSize
13.71 KB

Nice, thanks.

This also saved us from a global pollution, didn't think about passwordCheckMatch() populating this with a variable and then being called as a global function. Jshint didn't catch it as a function expression either, quite odd.

A good reason for these new conventions :)

So my solution is just to remove both possible classes before adding a new one, without checking if it exists or not. If you prefer using a closure to memorize, I'll revise it.

oxyc’s picture

Status: Needs work » Needs review
nod_’s picture

tag

droplet’s picture

+++ b/core/modules/user/user.jsundefined
@@ -9,85 +9,89 @@
+    var $innerWrapper = $passwordInput.parent();

Give a better name ? eg $passwordInputParent.

+++ b/core/modules/user/user.jsundefined
@@ -9,85 +9,89 @@
+    function passwordCheck () {
...
+    function passwordCheckMatch () {

no space "function()"

+++ b/core/modules/user/user.jsundefined
@@ -9,85 +9,89 @@
+    $passwordInput.on('keyup focus blur', passwordCheck);
+    $confirmInput.on('keyup blur', passwordCheckMatch);

add event namespaces ? should it bind "change" event ? and "input" event for IME

+++ b/core/modules/user/user.jsundefined
@@ -99,15 +103,15 @@ Drupal.behaviors.password = {
+  var $usernameBox = $('input.username');

can we call it $usernameInput

droplet’s picture

Assigned: Unassigned » droplet
Status: Needs review » Needs work

I will update it when #1684880: JSHint user get commited

droplet’s picture

Assigned: droplet » Unassigned
Status: Needs work » Needs review
FileSize
10.14 KB

Too many changes, won't attach an interdiff.

The last submitted patch, user.d8.patch, failed testing.

droplet’s picture

Status: Needs work » Needs review

#13: user.d8.patch queued for re-testing.

droplet’s picture

Issue summary: View changes
FileSize
9.51 KB
nod_’s picture

Status: Needs review » Needs work

Stray semi-colon in user.persmissions.js

the $dummy change looks good, you're right, no need to clone it.

The selector can even be transformed to be

  $table.find('input[type="checkbox"]:not(.rid-anonymous, .rid-authenticated)')

works the same for me.

Changes to user.js looks good :)

droplet’s picture

Status: Needs work » Needs review
FileSize
9.51 KB

I found it in user.js

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
@@ -84,7 +84,7 @@
       // Monitor input events.
       $passwordInput.on('input', passwordCheck);
       $confirmInput.on('input', passwordCheck);
-    };
+    }
   }
 };

2. the selectors transform I leave as it, no diff.

droplet’s picture

FileSize
10.04 KB

Nothing is perfect, Move On!.

Status: Needs review » Needs work

The last submitted patch, 19: 1751434-user.patch, failed testing.

droplet’s picture

Status: Needs work » Needs review
FileSize
9.6 KB

Try again, it applied locally

Manuel Garcia’s picture

Parent issue: » #1574470: Selectors clean-up
pguillard’s picture

nod_’s picture

Status: Needs review » Needs work

Seeing a few ESLint errors:


core/modules/user/user.js
   58:16  error  "$passwordSuggestions" used outside of binding context  block-scoped-var
   59:14  error  "$passwordSuggestions" used outside of binding context  block-scoped-var
   63:12  error  "$passwordSuggestions" used outside of binding context  block-scoped-var
   78:31  error  There should be no space after '{'                      space-in-brackets
   78:55  error  There should be no space before '}'                     space-in-brackets
   81:31  error  There should be no space after '{'                      space-in-brackets
   81:54  error  There should be no space before '}'                     space-in-brackets
   98:23  error  indicatorClass is defined but never used                no-unused-vars
  185:22  error  "indicatorColor" used outside of binding context        block-scoped-var
  185:22  error  "indicatorColor" is not defined                         no-undef

core/modules/user/user.permissions.js
  12:0  error  Keyword "if" must be followed by whitespace  space-after-keywords
  12:6  error  Expected indentation of 6 characters         indent
pguillard’s picture

I applied #24 corrections.
No clue for the indicatorClass warning

lauriii’s picture

Assigned: Unassigned » lauriii
lauriii’s picture

Assigned: lauriii » Unassigned
Status: Needs work » Needs review
FileSize
7.46 KB
13.53 KB
nod_’s picture

Status: Needs review » Needs work

Need reroll :/

Looks good though.

lauriii’s picture

Status: Needs work » Needs review
FileSize
12.52 KB
nod_’s picture

Status: Needs review » Needs work

indicatorColor is not used, why do we need that one, is anything else using it?

eslint error on the user.permission.js file.

pguillard’s picture

Status: Needs work » Needs review
FileSize
12.18 KB
912 bytes

I have problems with eslint, but here's what I suggest..

nod_’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me, eslint is happy.

Password is working as expected. Permission page too.

The last submitted patch, 25: drupal-clean_up_user_module-1751434-25.patch, failed testing.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

I've reviewed this and manually tested - all looks okay. Not the easiest issue to review as the changes seem to be from multiple scopes - internal clean ups and new js specific classes. Ideally this would be done in separate issues.

Given that we are preceding with other issues that add the js- I'm going to commit this patch as part of that effort. However, in future it would be great if the scope of the these patches could be reduced to just doing the necessary to do that. Committed 74363f6 and pushed to 8.0.x. Thanks!

  • alexpott committed 74363f6 on 8.0.x
    Issue #1751434 by droplet, oxyc, pguillard, lauriii, nod_: Selectors...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.