Bug Tracker

Opened 10 years ago

Closed 9 years ago

#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:
Blocked by: Blocking:

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 (2)

testcase.htm (452 bytes) - added by Sebmaster 10 years ago.
testcase showed the wrong situation
jquery-test.htm (360 bytes) - added by Sebmaster 10 years ago.
This seems to also occur when I use the jQuery() function itself.

Download all attachments as: .zip

Change History (6)

Changed 10 years ago by Sebmaster

Attachment: testcase.htm added

testcase showed the wrong situation

comment:1 Changed 10 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 10 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 10 years ago by Sebmaster

Attachment: jquery-test.htm added

This seems to also occur when I use the jQuery() function itself.

comment:3 Changed 10 years ago by Sebmaster

Fixed with jQuery 1.4.2.

comment:4 Changed 9 years ago by addyosmani

Keywords: textnodes replacewith added
Priority: majorlow
Resolution: fixed
Status: newclosed

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.

Note: See TracTickets for help on using tickets.