Opened 10 years ago
Closed 10 years ago
#12378 closed bug (invalid)
$.unique goes into an infinite loop in IE8 (slow script warning).
Reported by: | dangerbell | Owned by: | dangerbell |
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | unfiled | Version: | 1.8.0 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
The above jsFiddle will trigger a slow script warning in IE8 (but not Chrome, I haven't checked other IEs).
It seems to be the condition in the for
loop of Sizzle.uniqueSort
.
for ( ; (elem = results[i]); i++ ) { if ( elem === results[ i - 1 ] ) { results.splice( i--, 1 ); } }
In Chrome when results[i]
accesses an element that's been removed with splice
it returns undefined
. But in IE8 it seems that it can still access the element and assigns it to elem
. So the condition always ends up being true. Array indexes that are outside the original array's length return undefined
and results.length
returns the correct size. I have no idea why IE would do this.
The loop from jQuery 1.7.2 works properly because it's checking results.length
.
Change History (5)
comment:1 follow-up: 2 Changed 10 years ago by
Owner: | set to dangerbell |
---|---|
Status: | new → pending |
comment:2 Changed 10 years ago by
Status: | pending → new |
---|
Replying to dmethvin:
The documentation says:
This function only works on plain JavaScript arrays of DOM elements, and is chiefly used internally by jQuery. -- http://api.jquery.com/jQuery.unique/
You're passing it a jQuery object. Did you notice the documentation?
Oh. Yep, it works if you pass it a regular array. I guess I'll go report this as a bug in the plugin I was using. Thanks.
comment:4 Changed 10 years ago by
Status: | pending → new |
---|
Replying to dmethvin:
Great! Which plugin was this?
jqBootstrapValidation: http://reactiveraven.github.com/jqBootstrapValidation/
comment:5 Changed 10 years ago by
Resolution: | → invalid |
---|---|
Status: | new → closed |
I'll file a bug on their issue tracker, thanks!
The documentation says:
You're passing it a jQuery object. Did you notice the documentation?