Skip to main content

Bug Tracker

Side navigation

#7896 closed bug (invalid)

Opened January 04, 2011 07:00PM UTC

Closed January 06, 2011 05:59PM UTC

Last modified January 08, 2011 03:53AM UTC

Spin-lock on incorrect selector formatting

Reported by: dspillett Owned by:
Priority: undecided Milestone:
Component: unfiled Version: 1.4.4
Keywords: Cc:
Blocked by: Blocking:
Description

A minor bug here, only affecting badly formatted selectors.

In some cases missing out the closing ] causes jQuery to make the browser spin-lock. For instance the following causes the issue:

$('input[id^=bRun__'+KPISet+'__').attr('checked', true);

The correct code should of course be:

$('input[id^=bRun__'+KPISet+'__]').attr('checked', true);

The problem does not seem to be a change/event/change/event loop cause by updating the check boxes (the code above is in a function that responds to input change events, hence that sort of error in my logic was the first possibility considered) as the following causes the same behavior:

$('input[id^=bRun__'+KPISet+'__').each(function(index){ alert(index); });

Confirmed on IE6 (locks the browser instance completely, keeping one CPU core busy, it has to be killed via task manager or similar) and Chrome v8.0.552.224 (just locks the current tab, which can only be closed, keeping one CPU core busy until the tab is killed). I've not tested the issue on FireFox as yet.

This may be "behavior as designed" as you can't check for every possible error and the selector is obviously wrong in the above cases (well, it took me some minutes to spot the "obvious" but this is my first afternoon using jQuery so a more experienced user would have no doubt seen it sooner), but detecting the issue and reporting it instead of carrying on and falling into a non-terminating loop would be preferable.

Attachments (0)
Change History (3)

Changed January 04, 2011 07:02PM UTC by dspillett comment:1

_comment0: (I'll try add a minimal example to jsFiddle later/tomorrow, the working day is already late...)1294223591679014

My attempts to create a small case in jsFiddle that locks up this way have thus far failed (in each case the call just returned zero results which is what I'd expect if an exception isn't raised) - so presumably the issue is caused by something in the page's DOM in combination with the malformed selector.

I can still reproduce it reliably on the page I first saw the issue on, but you don't want to fight your way around all th extraneousness code! I can't spend more time on it here right now, so I'll take a copy and try hack it down to the minimum that shows the problem at the weekend.

Changed January 06, 2011 05:59PM UTC by rwaldron comment:2

resolution: → invalid
status: newclosed

Malformed selector strings are not jQuery bugs.

Changed January 08, 2011 03:53AM UTC by jitter comment:3

milestone: 1.6

In case you come up with a minimal reproducible test case it would be interesting to see it nonetheless.