Side navigation
#12378 closed bug (invalid)
Opened August 23, 2012 03:58AM UTC
Closed August 23, 2012 01:30PM UTC
$.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
forloop 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
spliceit 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
undefinedand
results.lengthreturns 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.
Attachments (0)
Change History (5)
Changed August 23, 2012 12:42PM UTC by comment:1
owner: | → dangerbell |
---|---|
status: | new → pending |
Changed August 23, 2012 01:06PM UTC by comment:2
status: | pending → new |
---|
Replying to [comment:1 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.
Changed August 23, 2012 01:07PM UTC by comment:3
status: | new → pending |
---|
Great! Which plugin was this?
Changed August 23, 2012 01:23PM UTC by comment:4
status: | pending → new |
---|
Replying to [comment:3 dmethvin]:
Great! Which plugin was this?
jqBootstrapValidation: http://reactiveraven.github.com/jqBootstrapValidation/
Changed August 23, 2012 01:30PM UTC by comment:5
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?