Skip to main content

Bug Tracker

Side navigation

#5434 closed enhancement (fixed)

Opened October 31, 2009 06:27AM UTC

Closed November 07, 2009 04:12PM UTC

$.fn.add( selector, context )

Reported by: rkatic Owned by:
Priority: major Milestone: 1.4
Component: core Version: 1.3.2
Keywords: add, context Cc:
Blocked by: Blocking:

1. The optional context will be applied on evolving the selector.

2. If the context argument is not given, then at lest use the same document.


Here the expected implementation:

Query.fn.add = function( selector, context ) {
    return this.pushStack( jQuery.unique( jQuery.merge(
        typeof selector === "string" ?
            jQuery( selector, context
                || this.context && this.context.ownerDocument || this.context)
                || this[0] && (this[0].ownerDocument || this[0]) ) :
            jQuery.makeArray( selector )

Attachments (0)
Change History (1)

Changed November 07, 2009 04:12PM UTC by john comment:1

resolution: → fixed
status: newclosed

The more I thought about it, the less sense "|| this.context && this.context.ownerDocument" made. The .add() method should use the context specified by the root selector call.

I've implemented this change along with test cases. Thanks for the preliminary patch!