Ticket #5806 (closed bug: fixed)
jQuery leaves textnodes in replaceWith
| Reported by: | Sebmaster | Owned by: | |
|---|---|---|---|
| Priority: | low | Milestone: | 1.4.1 |
| Component: | core | Version: | 1.4 |
| Keywords: | textnodes replacewith | Cc: | |
| Blocking: | Blocked by: |
Description
I think the title describes the problem pretty good. If i call replaceWith on a text node (in this case, don't have the time to test much further), replaceWith only replaces with content inside of HTML-tags.
It worked for me in jQuery 1.4a1 and jQuery 1.3.2. Might be related with #5483?
Attachments
Change History
Changed 3 years ago by Sebmaster
-
attachment
testcase.htm
added
comment:1 Changed 3 years ago by remysharp
I'm seeing this bug also, here's a test case comparing 1.3.2 against 1.4:
http://jsbin.leftlogic-staging.com/icigi/2/edit
You can also see it in the wild if as this technique of replacing textNodes is being used in Snap Bird:
http://snapbird.org/rem/favs/git
The text shouldn't read just "git" it should be the full tweet with git in bold.
comment:2 Changed 3 years ago by remysharp
On further investigation, since replaceWith uses detach to "clean" the string, I can verify that there's a bug in detach:
http://jsbin.leftlogic-staging.com/efeci/edit
The alert should show 'hello <i>world</i>', but only shows 'world'
Changed 3 years ago by Sebmaster
-
attachment
jquery-test.htm
added
This seems to also occur when I use the jQuery() function itself.
comment:4 Changed 3 years ago by addyosmani
- Keywords textnodes replacewith added
- Priority changed from major to low
- Status changed from new to closed
- Resolution set to fixed
As Sebmaster states, this appears to have been fixed in jQuery 1.4.2 and currently works through 1.4.3 and 1.4.4 RC2 http://jsfiddle.net/addyosmani/LReun/. Closing as fixed unless there are any comments to the contrary.
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

testcase showed the wrong situation