Skip to main content

Bug Tracker

Side navigation

#7212 closed bug (fixed)

Opened October 16, 2010 03:09PM UTC

Closed November 01, 2010 11:29PM UTC

Last modified March 09, 2012 11:55PM UTC

1.4.3 find() doesn't find elements when selecting from a form

Reported by: wolfsoft@mail.ru Owned by: john
Priority: blocker Milestone: 1.4.4
Component: selector Version: 1.4.3
Keywords: regression Cc:
Blocked by: Blocking:
Description
$(".message-delete-form").submit(function() {
  var form = $(this);
  alert(form.find("input[name='id']").length);
});

This code displays "0" with 1.4.3 and correct value "1" with 1.4.2. So I rolled back to 1.4.2 temporarily.

Attachments (0)
Change History (42)

Changed October 16, 2010 03:11PM UTC by anonymous comment:1

P.S. Firefox 3.6.10 (Ubuntu Linux)

Changed October 16, 2010 03:16PM UTC by addyosmani comment:2

owner: → wolfsoft@mail.ru
status: newpending

Are you able to provide your complete original test case for us to evaluate?

Changed October 16, 2010 06:44PM UTC by wolfsoft@mail.ru comment:3

status: pendingnew

Sure, here it is. Replace "1.4.3" to "1.4.2" and see the difference when pressing submit:

http://jsfiddle.net/tebT7/

Changed October 16, 2010 09:09PM UTC by snover comment:4

component: unfiledselector
keywords: → regression
priority: undecidedblocker
status: newopen

Changed October 18, 2010 06:40PM UTC by rwaldron comment:5

_comment0: If you change name="id" to name="foo" this bug resolves itself. See: http://ejohn.org/blog/deadly-expandos/ \ \ \ name="id" is not allowed \ \ \ Note, this was addressed by myself and Rebecca Murphey1287428145402455

If you change name="id" to name="foo" this bug resolves itself. See: http://ejohn.org/blog/deadly-expandos/

Consider this a "well known gotcha". Note, this was addressed by myself and Rebecca Murphey

Changed October 18, 2010 06:56PM UTC by snover comment:6

Fails in Firefox, and causes an Error to be raised in IE8. Works in Chrome, Opera, and Safari. Using common DOM words for input name or id attributes is inadvisable, but this should still work as it did in 1.4.2.

Changed October 18, 2010 08:31PM UTC by snover comment:7

summary: 1.4.3 find() doesn't find anything1.4.3 find() doesn't find elements when selecting from a form

Changed October 22, 2010 12:36AM UTC by snover comment:8

#7270 is a duplicate of this ticket.

Changed October 22, 2010 12:39AM UTC by snover comment:9

owner: wolfsoft@mail.ruaddyosmani
status: openassigned

Changed October 22, 2010 04:36AM UTC by jeresig comment:10

resolution: → fixed
status: assignedclosed

Make sure that we aren't reading one of the bad expandos. Fixes #7212.

Changeset: 4fc86d5eb1d4eaa3efad77dc224271d254f491e4

Changed October 25, 2010 08:51PM UTC by rwaldron comment:11

Documentation that this ticket is resolved in 1.4.4rc1

http://jsfiddle.net/rwaldron/tVXZj/

Changed October 26, 2010 11:35PM UTC by rwaldron comment:12

#7275 is a duplicate of this ticket.

Changed October 27, 2010 03:06PM UTC by addyosmani comment:13

#7324 is a duplicate of this ticket.

Changed October 27, 2010 05:44PM UTC by cybernetix@gmail.com comment:14

Replying to [comment:11 rwaldron]:

Documentation that this ticket is resolved in 1.4.4rc1 http://jsfiddle.net/rwaldron/tVXZj/

Firefox issue still persists.

This will work: console.log($("form").find("#id").length);

but this will not work: console.log($("#frm").find("#id").length);

<script type="text/javascript" language="javascript" src="http://code.jquery.com/jquery-1.4.4rc1.min.js" charset="utf-8"></script>
<script type="text/javascript">
$(function(){
	console.log($("form").find("#id").length);
	console.log($("form").find("[name=id]").length);
	console.log($("form").find(".cls").length);	
	console.log($("#frm").find("#id").length);
	console.log($("#frm").find("[name=id]").length);
	console.log($("#frm").find(".cls").length);
});
</script>
<form id="frm" name="frm">
    <input id="id" name="id" value="0" type="hidden" />
    <input class="cls" id="f1" name="f1" value="" type="text" />
</form>

Changed October 27, 2010 05:47PM UTC by anonymous comment:15

Replying to [comment:14 cybernetix@…]:

Replying to [comment:11 rwaldron]: > Documentation that this ticket is resolved in 1.4.4rc1 > > > http://jsfiddle.net/rwaldron/tVXZj/ Firefox issue still persists. This will work: console.log($("form").find("#id").length); but this will not work: console.log($("#frm").find("#id").length);
> <script type="text/javascript" language="javascript" src="http://code.jquery.com/jquery-1.4.4rc1.min.js" charset="utf-8"></script>
> <script type="text/javascript">
> $(function(){
> 	console.log($("form").find("#id").length);
> 	console.log($("form").find("[name=id]").length);
> 	console.log($("form").find(".cls").length);	
> 	console.log($("#frm").find("#id").length);
> 	console.log($("#frm").find("[name=id]").length);
> 	console.log($("#frm").find(".cls").length);
> });
> </script>
> <form id="frm" name="frm">
>     <input id="id" name="id" value="0" type="hidden" />
>     <input class="cls" id="f1" name="f1" value="" type="text" />
> </form>
> 

Also this will not work:

	console.log($("[name=frm]").find("#id").length);
	console.log($("[name=frm]").find("[name=id]").length);
	console.log($("[name=frm]").find(".cls").length);

Changed October 27, 2010 10:04PM UTC by snover comment:16

_comment0: '''Please do not paste test code in tickets!''' \ \ [http://jsfiddle.net/snover/tVXZj/1/ revised test case]1288217129883723
resolution: fixed
status: closedreopened

Please do not paste test code in tickets!

revised test case

Changed October 27, 2010 10:05PM UTC by snover comment:17

status: reopenedopen

Changed October 27, 2010 10:10PM UTC by snover comment:18

owner: addyosmani
status: openassigned

Changed October 27, 2010 10:10PM UTC by snover comment:19

status: assignedopen

Changed October 27, 2010 10:54PM UTC by dmethvin comment:20

resolution: → duplicate
status: openclosed

Changed October 27, 2010 10:54PM UTC by dmethvin comment:21

Duplicate of #3113.

Changed October 27, 2010 11:01PM UTC by dmethvin comment:22

resolution: duplicate
status: closedreopened

I that that back, it's the same phenomenon but not the same code/solution.

Changed October 28, 2010 06:59PM UTC by john comment:23

owner: → john
status: reopenedassigned

Changed October 29, 2010 12:14PM UTC by rwaldron comment:24

#7351 is a duplicate of this ticket.

Changed October 29, 2010 01:08PM UTC by anonymous comment:25

I'm experiencing the same issue.

This is a very serious issue. Especially for those whom rely on jQuery for development and use google APIs (and setting the script to fetch the latest update).

Changed October 31, 2010 04:00AM UTC by snover comment:26

#7356 is a duplicate of this ticket.

Changed November 01, 2010 11:29PM UTC by jeresig comment:27

resolution: → fixed
status: assignedclosed

Only change ID on nodes that don't already have an ID for rooted qSA. Fixes #7212.

Changeset: 62c83a764cdb3f6e7f6a9b696de1636570df19bf

Changed November 02, 2010 03:07AM UTC by snover comment:28

#7373 is a duplicate of this ticket.

Changed November 03, 2010 01:18PM UTC by snover comment:29

#7384 is a duplicate of this ticket.

Changed November 05, 2010 08:16AM UTC by addyosmani comment:30

#7407 is a duplicate of this ticket.

Changed November 05, 2010 11:38PM UTC by jeff@epochdev.com comment:31

Any word on a fix for this issue?

Changed November 08, 2010 11:21AM UTC by jitter comment:32

_comment0: Replying to [comment:31 jeff@…]: \ > Any word on a fix for this issue? \ \ This has already been fixed. You can see that by looking near the start of the page where it says \ \ > '''(closed bug: fixed)''' \ \ Also check [http://bugs.jquery.com/ticket/7212?replyto=31#comment:27 comment 27] where John set the ticket to fixed and provides a link. \ 1289215355407210

Replying to [comment:31 jeff@…]:

Any word on a fix for this issue?

This has already been fixed. You can see that by looking near the start of the page where it says

(closed bug: fixed)

Also check comment 27 where John set the ticket to fixed and provides a link.

Changed November 10, 2010 06:55PM UTC by rwaldron comment:33

#7460 is a duplicate of this ticket.

Changed December 01, 2010 03:03PM UTC by Richman777@gmail.com comment:34

This change seems to cause strange behavior for invalid HTML where there is an id attribute with a space in it. This isn't a problem if the id is properly formatted and doesn't have a space.

If an element has a space in the ID (it was being auto-generated on our side and it wasn't supposed to have one...but it did) then the find() won't return a successful result on a subset of the children nodes. In our specific case, a parent TD node had an id="FIRST SECOND" (example) and then the children of that cell was a table with a row and 3 cells. Even though I wasn't using the id attribute in the traversing or selecting of any elements, trying to find() the first child cell of the TD with the invalid ID attribute would always return an empty result.

However, I could do a find() for the second and third cells and they would return the correct elements.

Changed December 09, 2010 05:56PM UTC by rwaldron comment:35

#7738 is a duplicate of this ticket.

Changed March 14, 2011 02:34PM UTC by rwaldron comment:36

#8507 is a duplicate of this ticket.

Changed March 30, 2011 07:30PM UTC by rwaldron comment:37

#3113 is a duplicate of this ticket.

Changed April 01, 2011 03:26AM UTC by jcm@jaxcodemonkey.com comment:38

I do not believe this bug has been fixed. It is possible that I am not understanding the definition of 'fixed'. This bug still exists in Firefox, including Firefox 4, but does not occur in Chrome.

http://jsfiddle.net/aero2600/xv3KB/1/

Changed April 01, 2011 03:43AM UTC by timmywil comment:39

Replying to [comment:38 jcm@…]:

I do not believe this bug has been fixed. It is possible that I am not understanding the definition of 'fixed'. This bug still exists in Firefox, including Firefox 4, but does not occur in Chrome. http://jsfiddle.net/aero2600/xv3KB/1/

This bug has been fixed for 1.6, but this ticket is a duplicate of others currently open, such as #3113.

http://jsfiddle.net/timmywil/xv3KB/5/

Changed April 01, 2011 03:44AM UTC by timmywil comment:40

Sorry, I meant #3685.

Changed April 01, 2011 02:43PM UTC by jcm@jaxcodemonkey.com comment:41

Replying to [comment:40 timmywil]:

Sorry, I meant #3685.

Thank you for the heads up.

Changed June 06, 2011 01:20PM UTC by soulshards comment:42

I reached this bug report as I experienced odd jquery behavior resulting in returning broken element identifiers (selectors).

The bug was experienced on both Linux and Windows OS, respectively using browser FF 3.6.17 and FF 4.0.1

Jquery versions tested with are 1.4.2 and current 1.6.1 as of this comment.

Example of what I define as corruption/bug is available here: http://jsfiddle.net/98ZX9/

I tend to assume that the corruption I experienced is either related or as a result of the issue this bug report is referring to.