Skip to main content

Search and Top Navigation

#10525 closed bug (fixed)

Opened August 07, 2014 05:10PM UTC

Closed August 08, 2014 12:48PM UTC

Last modified August 08, 2014 12:49PM UTC

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.

Attachments (0)
Change History (7)

Changed August 07, 2014 05:23PM UTC by tj.vantoll comment:1

owner: → 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/.

Changed August 07, 2014 05:50PM UTC by pxc comment:2

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

});

Changed August 07, 2014 08:07PM UTC by tj.vantoll comment:3

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/.

Changed August 08, 2014 10:54AM UTC by pxc comment:4

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.

Changed August 08, 2014 12:46PM UTC by tj.vantoll comment:5

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.

Changed August 08, 2014 12:48PM UTC by TJ VanToll comment:6

resolution: → fixed
status: openclosed

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

Fixes #10525

Changeset: 36e4bfd516c10140d8517ed9e2eb067be2e5c837

Changed August 08, 2014 12:49PM UTC by tj.vantoll comment:7

milestone: none1.11.1