Opened 11 years ago
Closed 11 years ago
#8513 closed bug (invalid)
Infinite loop when calling .each() on a null element
Reported by: | Owned by: | ||
---|---|---|---|
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.
Change History (2)
comment:1 Changed 11 years ago by
Component: | unfiled → core |
---|---|
Owner: | set to [email protected]… |
Status: | new → pending |
comment:2 Changed 11 years ago by
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.