Bug Tracker

Modify

Ticket #12643 (closed bug: fixed)

Opened 19 months ago

Last modified 18 months ago

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:
Blocking: Blocked by:

Description

Hi,

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

comment:1 Changed 19 months ago by jason@…

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

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

in

function matcherFromTokens( tokens ) {

would save some grief. Thanks!

comment:2 Changed 19 months ago by dmethvin

The bare JavaScript method throws an error:

 http://jsfiddle.net/x7qFR/

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 19 months ago by gibson042

  • Owner set to gibson042
  • Priority changed from undecided to low
  • Status changed from new to assigned
  • Component changed from unfiled to selector
  • Milestone changed from None to 1.8.3

comment:4 Changed 19 months ago by Timmy Willison

  • Status changed from assigned to closed
  • Resolution set to fixed

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

Changeset: 52a84225596393879806ad9e024c3351c8b46034

comment:5 Changed 18 months ago by gibson042

#12718 is a duplicate of this ticket.

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.