#12643 closed bug (fixed)
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: |
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 (5)
comment:1 Changed 11 years ago by
comment:2 Changed 11 years ago by
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
Component: | unfiled → selector |
---|---|
Milestone: | None → 1.8.3 |
Owner: | set to gibson042 |
Priority: | undecided → low |
Status: | new → assigned |
comment:4 Changed 11 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Sizzle: throw an invalid selector exception for trailing-comma selectors. Fixes #12643.
Changeset: 52a84225596393879806ad9e024c3351c8b46034
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!