Skip to main content

Bug Tracker

Side navigation

#4323 closed bug (duplicate)

Opened March 10, 2009 03:42PM UTC

Closed October 03, 2009 02:04AM UTC

$('#' + myID) throws an exception in version 1.3.1 and 1.3.2 if myID is a zero length string

Reported by: psinkinson Owned by: john
Priority: minor Milestone: 1.4
Component: selector Version: 1.3.2
Keywords: Cc:
Blocked by: Blocking:

This may seem a little bit odd to be searching for an id-less element, but i found a few places in existing code that were in loops and the id variable had no value.

Previos versions returned a jQuery object with a length of zero, but from 1.3.1 an exception is thrown.

[Exception... "'Syntax error, unrecognized expression: #' when calling method: [nsIDOMEventListener::handleEvent]" nsresult: "0x8057001e (NS_ERROR_XPC_JS_THREW_STRING)" location: "<unknown>" data: no]

Attachments (0)
Change History (2)

Changed March 20, 2009 07:48AM UTC by JDay comment:1

I modified the ID and Class regexes to use '*', instead of '+' and it didn't break any tests in FF 3.0.7.

It's questionable whether this is the desired behavior, though. I don't think this approach would make sense when applied to attributes that aren't unique (should $('.') yield no elements, or all elements with no classes?).

Changed October 03, 2009 02:04AM UTC by dmethvin comment:2

resolution: → duplicate
status: newclosed

Essentially a dup of #4321.