Bug Tracker

Opened 12 years ago

Closed 12 years ago

#3741 closed bug (fixed)

Name selector with a context should fallback when context doesn't support getElementsByName [jQuery 1.3 Beta 1]

Reported by: chuyeow Owned by: john
Priority: major Milestone: 1.3
Component: selector Version: 1.2.6
Keywords: sizzle Cc: chuyeow
Blocked by: Blocking:

Description

I ran into this bug while testing jQuery 1.3b1:

$('input[name=foo', '#form');
=> Throws a context.getElementsByName is not a function error.

Turns out Sizzle will call getElementsByName even when there is a context argument passed to the selector, and this breaks when the context doesn't support getElementsByName. AFAIK this only works on document (i.e. no context).

I also found while fixing this bug that input[name="foo"] will NOT use the NAME selector (it falls back to the TAG-based selector).

I've a couple of patches to Sizzle that fixes these 2 bugs with tests over at my Github fork: http://github.com/chuyeow/sizzle/commits/context_selector_fixes (commits 19d4277 and be83e65).

I'll be generating a plain old patchfile as well in case that's more convenient :)

Attachments (2)

0002-Allow-name-selectors-with-quotes-e.g.-input-name.patch (2.2 KB) - added by chuyeow 12 years ago.
Allow input[name="foo"] (note the quotes) to use the name-based selector
0003-Call-getElementsByName-conditionally-in-NAME-selecto.patch (1.7 KB) - added by chuyeow 12 years ago.
Call getElementsByName conditionally in NAME selector

Download all attachments as: .zip

Change History (4)

Changed 12 years ago by chuyeow

Allow input[name="foo"] (note the quotes) to use the name-based selector

Changed 12 years ago by chuyeow

Call getElementsByName conditionally in NAME selector

comment:1 Changed 12 years ago by flesler

Cc: chuyeow added
Component: unfilledselector
Owner: changed from flesler to john

comment:2 Changed 12 years ago by john

Resolution: fixed
Status: newclosed
Version: 1.2.6

This has been landed in Sizzle and will be merged into jQuery core very soon.

Note: See TracTickets for help on using tickets.