Ticket #7896 (closed bug: invalid)
Spin-lock on incorrect selector formatting
| Reported by: | dspillett | Owned by: | |
|---|---|---|---|
| Priority: | undecided | Milestone: | |
| Component: | unfiled | Version: | 1.4.4 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
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.
Change History
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

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