Skip to main content

Bug Tracker

Side navigation

#6053 closed bug (invalid)

Opened February 08, 2010 12:43PM UTC

Closed February 10, 2010 05:37AM UTC

Cannot use unconnected dom nodes as context

Reported by: dwt Owned by:
Priority: Milestone: 1.4.2
Component: ajax Version: 1.4.1
Keywords: Cc:
Blocked by: Blocking:
Description
$ var a = $('<div id="bar" />')
$ a.get()
> [<div id=​"bar">​]
$ a.is('#bar')
> true
$ $('#bar', a).get()
> []
> $('#bar', a.get()).get()
> []

This should work. It would also make unit testing without actually stuffing something into the dom much easier (and faster as it would prevent the browser redraws).

Attachments (0)
Change History (2)

Changed February 08, 2010 12:45PM UTC by dwt comment:1

I just noticed that this works:

$ var a = $('<div><div id="bar" /></div>')
$ $('#bar', a).get()
> [<div id=​"bar">​]

Which is interesting. But would seem to pin the error to jquery not being able to find the context element itself?

Is that intentional?

Changed February 10, 2010 05:37AM UTC by john comment:2

resolution: → invalid
status: newclosed

You need to understand that $('#bar', a) is equivalent to doing: a.find("#bar") (as in, you're trying to find the #bar element inside of the 'a' element). It looks like you actually want: a.filter("#bar") (which will give you the results that only match the #bar selector.