Bug Tracker

Opened 14 years ago

Closed 13 years ago

#4323 closed bug (duplicate)

$('#' + 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]

Change History (2)

comment:1 Changed 14 years ago by JDay

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?).

comment:2 Changed 13 years ago by dmethvin

Resolution: duplicate
Status: newclosed

Essentially a dup of #4321.

Note: See TracTickets for help on using tickets.