Skip to main content

Bug Tracker

Side navigation

#12643 closed bug (fixed)

Opened October 03, 2012 03:41PM UTC

Closed October 04, 2012 01:50PM UTC

Last modified October 13, 2012 01:53AM UTC

Upgrade from 1.3.2 to 1.8.2 gives an Uncaught TypeError

Reported by: 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?

Attachments (0)
Change History (5)

Changed October 03, 2012 06:03PM UTC by comment:1

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!

Changed October 03, 2012 06:12PM UTC by dmethvin comment:2

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.

Changed October 03, 2012 08:06PM UTC by gibson042 comment:3

component: unfiledselector
milestone: None1.8.3
owner: → gibson042
priority: undecidedlow
status: newassigned

Changed October 04, 2012 01:50PM UTC by Timmy Willison comment:4

resolution: → fixed
status: assignedclosed

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

Changeset: 52a84225596393879806ad9e024c3351c8b46034

Changed October 13, 2012 01:53AM UTC by gibson042 comment:5

#12718 is a duplicate of this ticket.