Bug Tracker

Ticket #12449 (closed bug: fixed)

Opened 2 years ago

Last modified 22 months ago

replaceWith() doesn't clone elements where required

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

Description

(from  https://github.com/jquery/jquery/pull/920)

I thought I'd try jQuery over the new  comprehensive test suite we have for the various insertion methods in  Bonzo and discovered that jQuery's replaceWith() wasn't properly cloning where required.

Inside replaceWith() this.each() is used which then passes a singular collection for each element in this to before() or append() which then invokes domManip(), the clone check inside domManip() (see iNoClone = results.cacheable || l - 1 -- l always == 1).

Change History

comment:1 Changed 2 years ago by timmywil

  • Priority changed from undecided to high
  • Status changed from new to open
  • Component changed from unfiled to manipulation

Thanks for writing tests in the pull! Just for clarity's sake, do you have a fiddle somewhere that also demonstrates the problem?

comment:2 Changed 2 years ago by timmywil

  • Owner set to rod@…
  • Status changed from open to pending

comment:3 Changed 2 years ago by rod@…

  • Status changed from pending to new

@timmywil: this should do it:  http://jsfiddle.net/fHhKf/4/

comment:4 Changed 2 years ago by mikesherov

  • Status changed from new to assigned

comment:5 Changed 2 years ago by dmethvin

  • Milestone changed from None to 1.9

See additional discussion in  https://github.com/jquery/jquery/pull/920

comment:6 Changed 22 months ago by rwaldron

#13001 is a duplicate of this ticket.

comment:7 Changed 22 months ago by Rod Vagg

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

Fixes #12449. make replaceWith() clone elements where required. Closes gh-920

Changeset: 551c2c9f4ac776b6d53600c452ad40a4b4d6670b

Note: See TracTickets for help on using tickets.