Bug Tracker

Modify

Ticket #1449 (closed bug: fixed)

Opened 6 years ago

Last modified 6 years ago

parent method return duplicate elements

Reported by: blairmitchelmore Owned by:
Priority: minor Milestone: 1.1.4
Component: core Version: 1.1.3
Keywords: Cc:
Blocking: Blocked by:

Description

When you have multiple elements from the same parent elements in a jQuery array and then call parent, the resultant jQuery array contains multiple references to the same element.

Test case found at  http://jquery.offput.ca/tests/parent.php

The page will alert '6' and it should alert '1'

Attachments

1449.diff Download (335 bytes) - added by blairmitchelmore 6 years ago.
Fix for #1449

Change History

comment:1 Changed 6 years ago by blairmitchel

I've fixed the bug (if it is a bug and not a "feature") but simply calling jQuery.unique inside the .parent() method.

                var ret = jQuery.map(this,n);
                if ( a && typeof a == "string" )
                        ret = jQuery.multiFilter(a,ret);
-               return this.pushStack( ret );
+               return this.pushStack( jQuery.unique(ret) );
        };
 });

I don't see any major consequences from this and it would be an easy patch for jQuery core. (Of course you could also patch pushStack to ensure things are unique, but that could be overkill.)

Changed 6 years ago by blairmitchelmore

Fix for #1449

comment:2 Changed 6 years ago by john

  • Status changed from new to closed
  • Resolution set to fixed

Fixed in SVN rev [2769].

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.