Bug Tracker

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#12643 closed bug (fixed)

Upgrade from 1.3.2 to 1.8.2 gives an Uncaught TypeError

Reported by: alainahardie@… Owned by: gibson042
Priority: low Milestone: 1.8.3
Component: selector Version: 1.8.2
Keywords: Cc:
Blocked by: Blocking:



I just tried upgrading my app to 1.8.2 from 1.3.2. I tried 1.7.2 and saw the same thing. I get a message in the Chrome debugger that says:

Uncaught TypeError: Cannot read property 'type' of undefined jquery.min.js:2

Turns out that it was this selector that was breaking it:

 jQuery('#profile-photos .photo-set-container, #profile-photos .flexed-photo-set-container,')

Notice the trailing comma?

If I remove the trailing comma like so:

  jQuery('#profile-photos .photo-set-container, #profile-photos .flexed-photo-set-container')

... it works fine.

Now obviously the trailing comma is a bug, but it shouldn't kill JavaScript on the page. If the selector is null/undefined, whatever iterator is being used should ignore it, right?

Change History (5)

comment:1 Changed 11 years ago by jason@…

I just ran into this as well; a null check before getting to

leadingRelative = Expr.relative[ tokens[0].type ],


function matcherFromTokens( tokens ) {

would save some grief. Thanks!

comment:2 Changed 11 years ago by dmethvin

The bare JavaScript method throws an error:


So the old version was incorrect in accepting an invalid selector. I think the only question is whether this should be fixed to have jQuery (well Sizzle) throw its own "invalid selector" error rather than having an internal script error. Seems like we should do that.

comment:3 Changed 11 years ago by gibson042

Component: unfiledselector
Milestone: None1.8.3
Owner: set to gibson042
Priority: undecidedlow
Status: newassigned

comment:4 Changed 11 years ago by Timmy Willison

Resolution: fixed
Status: assignedclosed

Sizzle: throw an invalid selector exception for trailing-comma selectors. Fixes #12643.

Changeset: 52a84225596393879806ad9e024c3351c8b46034

comment:5 Changed 11 years ago by gibson042

#12718 is a duplicate of this ticket.

Note: See TracTickets for help on using tickets.