Skip to main content

Bug Tracker

Side navigation

#3741 closed bug (fixed)

Opened December 23, 2008 04:29AM UTC

Closed January 04, 2009 03:48PM UTC

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)
Change History (2)

Changed December 25, 2008 08:53PM UTC by flesler comment:1

cc: → chuyeow
component: unfilledselector
owner: fleslerjohn

Changed January 04, 2009 03:48PM UTC by john comment:2

resolution: → fixed
status: newclosed
version: → 1.2.6

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