Ticket #4321 (closed bug: fixed)
$("#") returns undefined
| Reported by: | vkvkvk | Owned by: | rwaldron |
|---|---|---|---|
| Priority: | low | Milestone: | 1.6 |
| Component: | selector | Version: | 1.4.3 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
$("#") returns "undefined". Opera ver 9.6 throws exception. Old version JQuery returns JQuery object (length=0)
Change History
comment:1 Changed 4 years ago by dmethvin
- Owner set to john
- Component changed from unfilled to selector
comment:2 Changed 4 years ago by davidserduke
Seems like a pretty specific and rare special case that isn't worth expanding the code base to fix. That said I think this might work and not require any more code (needs more testing though):
Change
quickExpr = /^[^<]*(<(.|\s)+>)[^>]*$|^#([\w-]+)$/
to
quickExpr = /^[^<]*(<(.|\s)+>)[^>]*$|^#([\w-]*)$/
which is just changing + which requires at least one character to * which doesn't (this special case where input is "#").
comment:3 Changed 3 years ago by rwaldron
- Keywords regression added
- Priority changed from major to low
- Version changed from 1.3.2 to 1.4.3
- Status changed from new to open
- Milestone changed from 1.4 to 1.4.4
Confirmed; However this is not documented in the API as a valid selector, however IS a regression in behaviour
exception thrown in 1.4.4rc1 http://jsfiddle.net/rwaldron/eHtAU/2/
passes with 1.2.6 http://jsfiddle.net/rwaldron/eHtAU/3/
comment:4 Changed 3 years ago by snover
- Keywords needsreview added
- Milestone 1.4.4 deleted
Retargeting to future since this is not likely to actually affect anyone.
comment:5 Changed 2 years ago by rwaldron
- Owner changed from john to rwaldron
- Status changed from open to assigned
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

It's an error case...I guess it should return an empty object though.