Bug Tracker

Ticket #13001 (closed feature: duplicate)

Opened 3 years ago

Last modified 3 years ago

replaceWith fails to replace all objects

Reported by: scaryclam Owned by: rwaldron
Priority: undecided Milestone: None
Component: unfiled Version: 1.8.2
Keywords: Cc:
Blocking: Blocked by:


I recently came across the following problem. When trying to use replaceWith on a class selector I found that when I pass an object, only the last matched element actually gets replaced. The rest get the appearance of being deleted. However, when using replaceWith with a string as the replacement it functions as I originally expected.

I created the following fiddle to demonstrate the issue:  http://jsfiddle.net/xksNb/

I don't think that this is a bug as the documentation states that when getting a DOM object and using it for the replacement, it will not be cloned. However, this seems unintuitive when creating a NEW object as a local variable and then trying to use that to replace elements. It would be nice if the docs made it clearer that this is the designed behaviour or if it was possible to create a new object and have it act like a string replace.

Hope that was all clear!

Becky Lewis

Change History

comment:1 Changed 3 years ago by rwaldron

  • Owner set to rwaldron
  • Status changed from new to assigned

comment:2 Changed 3 years ago by rwaldron

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

Duplicate of #12449.

Note: See TracTickets for help on using tickets.