Side navigation
#8513 closed bug (invalid)
Opened March 13, 2011 10:14AM UTC
Closed March 25, 2011 05:26PM UTC
Infinite loop when calling .each() on a null element
Reported by: | adrian.silimon@yahoo.com | Owned by: | adrian.silimon@yahoo.com |
---|---|---|---|
Priority: | undecided | Milestone: | 1.next |
Component: | core | Version: | 1.4.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
I noticed then when you call a jQuery('.unexistent-selector').each(function(){ ... do smthing ...}); generates an infinite loop.
I marked this as a bug, as I think this should not happen since the element does not exists in the DOM tree. I think it would be better to raise an "undefined" exception - so notice the user that the element(s) he wants to iterate through could't be found.
Attachments (0)
Change History (2)
Changed March 14, 2011 02:32PM UTC by comment:1
component: | unfiled → core |
---|---|
owner: | → adrian.silimon@yahoo.com |
status: | new → pending |
Changed March 25, 2011 05:26PM UTC by comment:2
resolution: | → invalid |
---|---|
status: | pending → closed |
Using rwaldron's test case above, I haven't been able to replicate this issue either. There doesn't seem to be any evidence of an infinite loop occurring.
In addition, although there are a number of cases where we potentially could output an undefined exception internally, if you absolutely need this you could easily test for element existence prior to using $.each manually.
I cannot reproduce the error.
http://jsfiddle.net/rwaldron/yKVW8/
If you believe this is an incorrect assessment, please provide a reduced jsFiddle test case!
Additionally, test against the jQuery 0 GIT version to ensure the issue still exists.