#13233 closed bug (fixed)
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.
Change History (10)
comment:2 Changed 10 years ago by
So, any guidance on how to change this function to work around this change? How do I get access to the manipulated set?
comment:3 Changed 10 years ago by
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.
comment:4 Changed 10 years ago by
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.
comment:5 Changed 10 years ago by
Milestone: | None → 1.9.1 |
---|---|
Owner: | set to gibson042 |
Status: | new → assigned |
Replying to 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.
comment:7 Changed 10 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Fix #13233: re-allow .replaceWith of text nodes. Close gh-1137.
Changeset: 6b1b0a26b4d485b4d9f334286efed5dfe33e3f3f
comment:8 Changed 10 years ago by
Fix #13233: re-allow .replaceWith of text nodes. Close gh-1137. (cherry picked from commit 6b1b0a26b4d485b4d9f334286efed5dfe33e3f3f)
Changeset: a96aa9e2709b4ba132b966a0f1a13d0e8eb49b9a
comment:10 Changed 10 years ago by
Component: | unfiled → manipulation |
---|---|
Priority: | undecided → low |
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.