Follow-up of #1664940: [Policy, patch] Decide on JSHint configuration and part of #1415788: Javascript winter clean-up

Run jshint on the files with the configuration from the parent issue or use jshint.com with the following options:

/*jshint forin:true, noarg:true, eqeqeq:true, undef:true, curly:true, browser:true, expr:true, latedef:true, newcap:true, trailing:true */
/*global Drupal, jQuery */

Fix any warnings or errors the tool finds.
Check manually that the fixes did not break any functionalities
Create patch and upload for the testbot.

Files: autocomplete.js

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

nod_’s picture

core/misc/autocomplete.js: line 228, col 52, Don't make functions within a loop.
core/misc/autocomplete.js: line 229, col 55, Don't make functions within a loop.
core/misc/autocomplete.js: line 230, col 56, Don't make functions within a loop.
core/misc/autocomplete.js: line 315, col 9, 'alert' is not defined.
droplet’s picture

Status: Active » Needs review
FileSize
1.34 KB
nod_’s picture

Status: Needs review » Postponed

Waiting on #675446: Use jQuery UI Autocomplete to get in to avoid reroll.

nicothezulu’s picture

Issue tags: -JavaScript clean-up

When u have input fields with the same id for multiple autocomplete fields over a panel, or page, or smthg autocomplete fails.

You need to add the following lines in autocomplete.js:

Drupal.behaviors.autocomplete = function (context) {
  var acdb = [];
  $('input.autocomplete:not(.autocomplete-processed)', context).each(function () {
     var parentForm = $(this).closest("form"); //ADD THIS
     var idParent = '#'+parentForm.attr('id'); //ADD THIS
     var uri = this.value;
     if (!acdb[uri]) {
        acdb[uri] = new Drupal.ACDB(uri);
     }
      var input = $(idParent+' #' + this.id.substr(0, this.id.length - 13)).attr('autocomplete', 'OFF')[0]; //CHANGE THIS
     .
     .
     .

I know its a separate issue, than this post...

nod_’s picture

Issue tags: +JavaScript clean-up

If you know it, please create a new issue, this has nothing to do with JSHint. Thanks.

Restoring tags.

nod_’s picture

Status: Postponed » Needs work

Let's get rid of that, the other issue isn't moving very much.

core/misc/autocomplete.js: line 230, col 52, Don't make functions within a loop.
core/misc/autocomplete.js: line 231, col 55, Don't make functions within a loop.
core/misc/autocomplete.js: line 232, col 56, Don't make functions within a loop.
nod_’s picture

Status: Needs work » Needs review
FileSize
919 bytes

event delegation ftw.

Status: Needs review » Needs work
Issue tags: -JavaScript clean-up

The last submitted patch, core-jshint-autocomplete-1684792-7.patch, failed testing.

nod_’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, core-jshint-autocomplete-1684792-7.patch, failed testing.

Wim Leers’s picture

Status: Needs work » Needs review
Issue tags: +JavaScript clean-up
nod_’s picture

Status: Needs review » Reviewed & tested by the community

Just re-tested. It still works and still applies.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

One more file to go and jshint can go into my pre-commit hook :)

Committed 9f69e00 and pushed to 8.x. Thanks!

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