Skip to main content

Bug Tracker

Side navigation

#13233 closed bug (fixed)

Opened January 16, 2013 03:40PM UTC

Closed January 16, 2013 06:55PM UTC

Last modified February 04, 2013 02:07AM UTC

Unexpected behavior when iterating over and manipulating detached nodes in jquery 1.9

Reported by: octatone Owned by: gibson042
Priority: low Milestone: 1.9.1
Component: manipulation Version: 1.9.0
Keywords: Cc:
Blocked by: Blocking:
Description

I have a convenience method that I use to wrap text elements in a html string in spans. In 1.8.3 and before it has worked as intended. I wanted to upgrade to 1.9.0, but am finding my function breaks and that manipulation on detached nodes and their child elements to not reflect correctly. Child elements seem to not be connected to the original node and any changes are not present on the parent.

I created an example case here:

1.8.3: http://jsfiddle.net/octatone/cAmD5/

1.9.0: http://jsfiddle.net/octatone/dMYeB/

In 1.8.3 all child text nodes are wrapped in spans. In 1.9 the result is that the html of the node is never changed and subsequently the returned result is not correct.

Attachments (0)
Change History (10)

Changed January 16, 2013 03:46PM UTC by dmethvin comment:1

_comment0: You're affected by this change: \ \ http://stage.jquery.com/upgrade-guide/1.9/#after-before-and-replacewith-with-disconnected-nodes \ \ As the guide says, we made this change so that the methods didn't have inconsistent behavior on the stack and set. 1358359482465463

You're affected by this change:

http://jquery.com/upgrade-guide/1.9/#after-before-and-replacewith-with-disconnected-nodes

As the guide says, we made this change so that the methods didn't have inconsistent behavior on the stack and set.

Changed January 16, 2013 03:52PM UTC by octatone comment:2

So, any guidance on how to change this function to work around this change? How do I get access to the manipulated set?

Changed January 16, 2013 03:58PM UTC by dmethvin comment:3

You could use .map() instead and return a newly created text node with the modifications. There is probably some cleaner way to do this but I haven't wrapped my head around the use case.

Changed January 16, 2013 03:59PM UTC by octatone comment:4

The use case is to preserve html, but wrap text in spans ... basically to make each char clickable. Regardless of it's parent html element. Anchors, divs, etc.

Changed January 16, 2013 04:52PM UTC by dmethvin comment:5

_comment0: Replying to [comment:1 dmethvin]: \ > You're affected by this change: \ > \ > http://stage.jquery.com/upgrade-guide/1.9/#after-before-and-replacewith-with-disconnected-nodes \ > \ > As the guide says, we made this change so that the methods didn't have inconsistent behavior on the stack and set. \ \ I thought so too, but it seems like this regression actually stems from a `nodeType` restriction introduced in [https://github.com/jquery/jquery/commit/551c2c9f4ac776b6d53600c452ad40a4b4d6670b].1358359565302472
milestone: None1.9.1
owner: → gibson042
status: newassigned

Replying to [comment:1 dmethvin]:

You're affected by this change: http://jquery.com/upgrade-guide/1.9/#after-before-and-replacewith-with-disconnected-nodes As the guide says, we made this change so that the methods didn't have inconsistent behavior on the stack and set.

I thought so too, but it seems like this regression actually stems from a nodeType restriction introduced in https://github.com/jquery/jquery/commit/551c2c9f4ac776b6d53600c452ad40a4b4d6670b.

Changed January 16, 2013 05:58PM UTC by gibson042 comment:6

Changed January 16, 2013 06:55PM UTC by Richard Gibson comment:7

resolution: → fixed
status: assignedclosed

Fix #13233: re-allow .replaceWith of text nodes. Close gh-1137.

Changeset: 6b1b0a26b4d485b4d9f334286efed5dfe33e3f3f

Changed January 16, 2013 06:57PM UTC by Richard Gibson comment:8

Fix #13233: re-allow .replaceWith of text nodes. Close gh-1137.

(cherry picked from commit 6b1b0a26b4d485b4d9f334286efed5dfe33e3f3f)

Changeset: a96aa9e2709b4ba132b966a0f1a13d0e8eb49b9a

Changed January 21, 2013 07:10PM UTC by timmywil comment:9

#13280 is a duplicate of this ticket.

Changed February 04, 2013 02:07AM UTC by dmethvin comment:10

component: unfiledmanipulation
priority: undecidedlow