Skip to main content

Bug Tracker

Side navigation

#5806 closed bug (fixed)

Opened January 14, 2010 11:48PM UTC

Closed November 10, 2010 09:34PM UTC

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)
  • jquery-test.htm (0.4 KB) - added by Sebmaster January 27, 2010 10:13AM UTC.

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

  • testcase.htm (0.4 KB) - added by Sebmaster January 14, 2010 11:51PM UTC.

    testcase showed the wrong situation

Change History (4)

Changed January 17, 2010 10:22AM UTC by remysharp comment:1

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.

Changed January 17, 2010 11:36AM UTC by remysharp comment:2

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 February 17, 2010 08:57AM UTC by Sebmaster comment:3

Fixed with jQuery 1.4.2.

Changed November 10, 2010 09:34PM UTC by addyosmani comment:4

keywords: → textnodes replacewith
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.