Bug Tracker

Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#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:
Blocked by: Blocking:


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 (3)

comment:1 Changed 12 years ago by dspillett

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

Version 0, edited 12 years ago by dspillett (next)

comment:2 Changed 12 years ago by Rick Waldron

Resolution: invalid
Status: newclosed

Malformed selector strings are not jQuery bugs.

comment:3 Changed 12 years ago by jitter

Milestone: 1.6

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

Note: See TracTickets for help on using tickets.