Skip to main content

Bug Tracker

Side navigation

#7904 closed bug (duplicate)

Opened January 05, 2011 03:29PM UTC

Closed January 05, 2011 03:52PM UTC

Last modified January 05, 2011 03:53PM UTC

$(element).add(selector) incorrectly uses element as the default context

Reported by: cracked@dds.nl Owned by:
Priority: undecided Milestone: 1.next
Component: unfiled Version: 1.4.4
Keywords: Cc:
Blocked by: Blocking:
Description

When doing:

$(element).add(selector)

the context for the selector defaults to element, rather than the document. While this can easily be fixed by explicitly specifying the context, this behavior can have unexpected and undesired results. For example in an HTML document:

// This effectively results in all elements being added
$('body').add('*');

// Surprisingly, the following calls are equivalent, adding
// only the document and its children
$(document.body).add('*');
$(document.body).find('*').andSelf();
Attachments (0)
Change History (3)

Changed January 05, 2011 03:37PM UTC by cracked@dds.nl comment:1

Note a typo in the last comment, which apparently I can't edit:

''[...] adding only the ~~document~~ body and its children''

Changed January 05, 2011 03:52PM UTC by ajpiano comment:2

resolution: → duplicate
status: newclosed

Changed January 05, 2011 03:53PM UTC by ajpiano comment:3

Duplicate of #7853.