Bug Tracker

Modify

Ticket #4323 (closed bug: duplicate)

Opened 4 years ago

Last modified 4 years ago

$('#' + 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:
Blocking: Blocked by:

Description

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

comment:1 Changed 4 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 4 years ago by dmethvin

  • Status changed from new to closed
  • Resolution set to duplicate

Essentially a dup of #4321.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.