Bug Tracker

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#12664 closed bug (fixed)

.after()

Reported by: msh6180339@… Owned by: msh6180339@…
Priority: high Milestone: None
Component: manipulation Version: 1.8.0
Keywords: Cc:
Blocked by: Blocking:

Description

jQuery 1.8.0, 1.8.1 and 1.8.2: $collection.after($elem) adds $elem to $collection jQuery set.

Change History (8)

comment:1 Changed 7 years ago by dmethvin

Owner: set to msh6180339@…
Status: newpending

Can you provide a test case on jsfiddle.net?

comment:2 in reply to:  1 Changed 7 years ago by Mehdi Shojaei <msh6180339@…>

Replying to dmethvin:

Can you provide a test case on jsfiddle.net?

Hi. jsfiddle.net test case link: http://jsfiddle.net/msh6180339/5jkHm/

Thanks a lot.

comment:3 Changed 7 years ago by mikesherov

Component: unfiledmanipulation
Keywords: 1.9-discuss added
Priority: undecidedhigh
Status: pendingopen

What should .after() and .before() do to the current set vs. the pushStack set?

comment:4 Changed 7 years ago by dmethvin

As we discussed, the problem is that .after(content) was intended to have two different behaviors:

  • If the first element in the jQuery set is connected to a document, the content is placed after each element in the set, and the original set is returned.
  • If the first element in the jQuery set is disconnected, the content is added to the end of a new (pushStack()ed) set, and that is returned.

We've had this broken in different ways in different versions. I think we should remove the second behavior and always treat elements the same way.

comment:6 Changed 7 years ago by Sai Wong

Resolution: fixed
Status: openclosed

Refactored before/after/replaceWith to not pushStack. Fixes #12664, closes gh-987

Changeset: 0c1cea376196d24acc73c64dbdff1880a2dfd006

comment:7 Changed 7 years ago by mehdishojaei

I think this refactoring makes before/after/replaceWith more obvious and cause them to work more naturally.

Thank you all.

comment:8 Changed 7 years ago by dmethvin

Keywords: 1.9-discuss removed
Note: See TracTickets for help on using tickets.