Bug Tracker

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#11147 closed bug (invalid)

1.7.1 altered event behavior for UI autocompleteselect event

Reported by: gvwalsh Owned by: gvwalsh
Priority: undecided Milestone: None
Component: unfiled Version: 1.7.1
Keywords: Cc:
Blocked by: Blocking:

Description

Using JQuery 1.7.1 the behavior of the Jquery AutoComplete autocompleteselect event is different from 1.6.1. The "event.target" is no longer the text box INPUT element associated with the plugin but is instead the dynamically created A element from the suggestion list. This results in the following example "delegate" no longer catching the event. Using JQuery 1.6.1 the event is in fact caught and event.target is set to the INPUT element.

('body').delegate('input', 'autocompleteselect', function(event, ui) { blah blah blah);

However, even under JQuery 1.7.1 the code

$('input').bind('autocompleteselect', function(event, ui) { blah blah blah );

catches the event but the "event.target" is the A element. However "event.currentTarget" is the INPUT element. I do not know enough about the DOM to understand the difference between event.target and event.currentTarget.

This is at the very least a puzzling incompatibility which resulted in existing code stopping working and it smells like a bug. I suspect it is related to the new unified event handling of 1.7.1

Change History (9)

comment:1 Changed 8 years ago by Rick Waldron

Owner: set to gvwalsh
Status: newpending

Thanks for taking the time to contribute to the jQuery project! Please provide a complete reduced test case on jsFiddle to help us assess your ticket!

Additionally, be sure to test against the "jQuery (edge)" version to ensure the issue still exists. To get you started, use this boilerplate: http://jsfiddle.net/FrKyN/ Open the link and click to "Fork" (in the top menu) to begin.

comment:2 in reply to:  1 Changed 8 years ago by gvwalsh

Status: pendingnew

http://jsfiddle.net/gvwalsh/zN2e3/ demonstrates new behavior against JQuery edge

http://jsfiddle.net/gvwalsh/ppe3a/ demonstrates the "working" behavior against JQuery 1.5.2

type "ab" into the text box and then select one of the suggestions. The version with 1.5.2 displays a "got here" alert indicating the event was caught. The latest version never gets to the alert. However the autocomplete does fill in the text box with the selected suggestion.

comment:3 Changed 8 years ago by Rick Waldron

Resolution: invalid
Status: newclosed

jQuery UI 1.8.9 was released in January 2011 http://blog.jqueryui.com/2011/01/jquery-ui-1-8-9/

jQuery 1.7 was released in November 2011 http://blog.jquery.com/2011/11/03/jquery-1-7-released/

Safe to say that jQuery UI 1.8.9 isn't compatible with the latest jQuery

comment:4 Changed 8 years ago by gvwalsh

The problem originally surfaced using JQuery UI 1.8.16 which, by my thinking should certainly be supported by the latest version of the JQuery core. I did not create a fiddle test case using this version of UI since the 1.8.9 version is the latest version that jsfiddle apparently offers for easy inclusion. The symptoms that appear in my full application using JQuery UI 1.8.16 appear identical to what happens with 1.8.9.

By the way the Yii framework distributes UI 1.8.16 with JQuery 1.7.1 which is where I originally encountered the problem - upgrading a working application to Yii 1.1.9 where it stopped working because of this autocomplete event problem.

comment:5 Changed 8 years ago by Rick Waldron

jQuery 1.8.16 was released in August, 2011 http://blog.jqueryui.com/2011/08/jquery-ui-1-8-16/

Please file a ticket with Yii - they shouldn't be mixing and matching jQuery UI with incompatible versions of jQuery

comment:6 Changed 8 years ago by gvwalsh

So what version of JQuery UI should be used with JQuery core 1.7.1? The current stable UI version is 1.8.17 which would be, by the customary way software versions are numbered, only a very minor difference away from 1.8.16. Are you saying that only UI version 1.8.17 has the changes that make it work properly with core 1.7.1? (and does it in fact work? - is there an easy way to test this with jsfiddle? Is there general guidance on compatibility anywhere?

comment:8 in reply to:  7 Changed 8 years ago by gvwalsh

I have now tested UI 1.8.17 / core 1.7.1 and the problem is in fact gone! ...i.e. the autocompleteselect event is now caught by delegate('input' ...

However, I am very curious as to the nature of the change in the core that provoked this problem and whether there are other subtle bugs to be expected in user code. It appears given my experiment with bind where the target seems to have changed from the INPUT element to the A element it appears that the new event handling model of 1.7.1 may provoke other problems in previously working code.

I also question the compatibility philosophy expressed by rwaldron. At the time Yii 1.1.9 was released there was no released UI 1.8.17 in existance and 1.8.16 was the best that could be had. I don't think there was any general awareness that there were incompatibilities.

comment:9 Changed 8 years ago by dmethvin

We have more than 5,000 unit tests for jQuery, and we run the jQuery UI unit tests before a release as well, plus we plead with the entire community to please please pretty-please-with-sugar-on-top test the pre-release versions before we go final--for example, you tested with the pre-release versions, right?

And then we ship. When someone finds a bug that wasn't covered by one of the existing tests, the best we can do is to fix it and add some more unit tests to ensure it doesn't happen again.

If we had a time machine, we could do much better of course. I would send rwaldron back to 2011 to insert the new unit tests into the 1.6 branch so that we would not introduce those bugs in 1.7. But then he would get cocky and decide to kill Bin Laden himself and really mess up the timeline because it turns out he kills Bin Laden on Friday and Rebecca Black's song becomes the patriotic anthem for the whole country and we have to listen to it before every major sporting event.

So all things considered, this bug isn't so bad.

Note: See TracTickets for help on using tickets.