Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#10525 closed bug (fixed)

Autocomplete - stray reference to jQuery.trim

Reported by: pxc Owned by: pxc
Priority: minor Milestone: 1.11.1
Component: ui.autocomplete Version: 1.11.0
Keywords: Cc:
Blocked by: Blocking:

Description

Produces "TypeError: jQuery is undefined" when using jquery migrate plugin. Replacing jQuery.trim() with $.trim() seems to remove the console warning.

Hopefully that suggested fix is correct and so trivial you dont need this info:

Its the only reference to jQuery.trim in the autocomplete code, but in the unlikely event that you're struggling to find it, its in the menufocus handler near the comment " Announce the value in the liveRegion".

To reproduce

  1. enable migrate plugin!
  2. type into an autocomplete to produce drop down options
  3. mouse over the options, warning for each option elem

It occurred on Firefox 20 on 32-bit linux. Its very probably not relevant.

Change History (7)

comment:1 Changed 3 years ago by tj.vantoll

Owner: set to pxc
Status: newpending

Hi pxc,

Thanks for taking the time to contribute to jQuery UI. Could you create a test case that shows this issue? I'm not seeing it in my test: http://jsfiddle.net/tj_vantoll/s390cfnr/.

comment:2 Changed 3 years ago by pxc

Status: pendingnew

Sorry, I forgot the one other vital piece of info - you have to $.noConflict() too. I dont have a fiddle account but this mod to your example should do it ...

var $j = $.noConflict(true);

var availableTags = ["ActionScript", "AppleScript", "Asp", "BASIC", "C", "C++", "Clojure", "COBOL", "ColdFusion", "Erlang", "Fortran", "Groovy", "Haskell", "Java", "JavaScript", "Lisp", "Perl", "PHP", "Python", "Ruby", "Scala", "Scheme"];

$j("#autocomplete").autocomplete({

source: availableTags

});

comment:3 Changed 3 years ago by tj.vantoll

Status: newpending

You don't need an account to play with the test case. When you can recreate the problem click the “Update” button and you'll get a URL you can share.

I don't have any issues when I add a noConflict call: http://jsfiddle.net/tj_vantoll/s390cfnr/1/.

comment:4 Changed 3 years ago by pxc

Status: pendingnew

Your updated example (thanks!) produces a javascript console error message

  • "TypeError: jQuery is undefined" on firefox v34 64bit on win 7, and firefox v20 32bit on ubuntu
  • "Uncaught TypeError: Cannot read property 'trim' of undefined " on chrome v36 Win7 and chrome v27 32bit on ubuntu
  • "Uncaught exception: TypeError: Cannot convert 'jQuery' to object" on opera v12.16 win7 and v12.16 on ubuntu

I'd expect it to produce some form of console error/warning on all browser variants. Theres a syntactical namespace conflict - the call to jQuery.trim() should be $.trim() like all other calls to jQuery api in the same component package.

The lines in error seem to be related to aria screen readers. I doubt it causes any noticeable functional problem on non-impaired kit, you wont "see" anything broken visually.

comment:5 Changed 3 years ago by tj.vantoll

Status: newopen
Summary: jqueryui autocomplete - stray reference to jQuery.trimAutocomplete - stray reference to jQuery.trim

Ah ok. This isn't happening because of the migrate plugin; it's happening because you're passing true to noConflict(), which removes the jQuery global variable. We require that global variable be in place, but I'm fine switching to $.trim for consistency with the rest of the codebase.

comment:6 Changed 3 years ago by TJ VanToll

Resolution: fixed
Status: openclosed

Autocomplete: Use $.trim instead of jQuery.trim for consistency

Fixes #10525

Changeset: 36e4bfd516c10140d8517ed9e2eb067be2e5c837

comment:7 Changed 3 years ago by tj.vantoll

Milestone: none1.11.1
Note: See TracTickets for help on using tickets.