Bug Tracker

Opened 8 years ago

Closed 7 years ago

#5316 closed bug (fixed)

replaceAll only the first element from the matched set replaces the selector set

Reported by: TUSHKA Owned by:
Priority: high Milestone: 1.4.3
Component: manipulation Version: 1.4.2
Keywords: Cc:
Blocked by: Blocking:

Description

var jq = $("<selector1>") selects more than one element jq.replaceAll("<selector2>")

only the first matched element from jq will show up as the replacement for "<selector2>"

Possible Fix: See Attachment

Attachments (2)

jquery.txt (861 bytes) - added by TUSHKA 8 years ago.
Possible Fix
jquery-replaceall-testcase.html (1.6 KB) - added by Perceptes 8 years ago.
A test case to show the issue, run it in a browser to see what's happening.

Download all attachments as: .zip

Change History (5)

Changed 8 years ago by TUSHKA

Attachment: jquery.txt added

Possible Fix

comment:1 Changed 8 years ago by TUSHKA

Possible fix, invoke replaceWith using call rather than apply. This will affect appendTo/append, prependTo/prepend, insertBefore/before, insertAfter/after as well, but it seems like those will work regardless of whether they are invoked via call or apply

comment:2 Changed 8 years ago by Troanis

Hello,

My workaround until fixed jq.wrap('<div/>').parent().replaceAll("<selector2>").replaceWith(jq)

Changed 8 years ago by Perceptes

A test case to show the issue, run it in a browser to see what's happening.

comment:3 Changed 7 years ago by jitter

Component: coremanipulation
Milestone: 1.41.4.3
Priority: minorhigh
Resolution: fixed
Status: newclosed
Version: 1.3.21.4.2

test case fixed for 1.4.3

Note: See TracTickets for help on using tickets.