Bug Tracker

Opened 12 years ago

Closed 10 years ago

#9960 closed bug (fixed)

Append function not working for parent nodes that are nodeType === 9

Reported by: [email protected] Owned by: coopersemantics
Priority: low Milestone: 1.next
Component: manipulation Version: 1.6.2
Keywords: Cc:
Blocked by: Blocking:


I encountered this problem while I was trying to replace the root node of an xml with another one. I was using replaceWith which in this case first removes the old one and then appends the new one to the xml document.

This works id the parent of the node to be replaced is not the XMLDocument (nodeType===9) itself (works for normal element nodes).

I made an test jfiddle for this case: http://jsfiddle.net/FranPregernik/ZVMeq

The fix is in the test code. You can enable it by uncommenting the append function. Then both tests will pass.

I can't seem to find if this behavior is desired or was the nodeType === 9 just accidentally neglected.

Change History (10)

comment:1 Changed 12 years ago by [email protected]

Tested on: Chrome 13, Firefox 5, IE9

comment:2 Changed 12 years ago by dmethvin

Status: newopen

I think this wasn't found before because in an HTML document it would be unusual to append elements to the document element. Seems valid for XML though and your patch should do the trick. Many thanks for the clear test case!

comment:3 Changed 12 years ago by dmethvin

A couple of notes: 1) The test case throws an error in IE7 for the second test. 2) The xml() helper could be replaced with $.parseXML() now but it's fine as-is.

comment:4 Changed 12 years ago by FranPregernik

Update: removed the xml helper and using parseXml at http://jsfiddle.net/FranPregernik/ZVMeq/15/

comment:5 Changed 11 years ago by dmethvin

Component: unfiledmanipulation
Milestone: None1.next
Priority: undecidedlow

comment:6 Changed 11 years ago by sindresorhus

#11169 is a duplicate of this ticket.

comment:7 Changed 10 years ago by mikesherov

Owner: set to mikesherov
Status: openassigned

comment:8 Changed 10 years ago by mikesherov

Owner: changed from mikesherov to coopersemantics

comment:10 Changed 10 years ago by dcooper

Resolution: fixed
Status: assignedclosed

Fix #9960, allow manipulation for parent document nodes. Close gh-924.

Changeset: 78c1560065e664213ac0cbea7518d442a58b0018

Note: See TracTickets for help on using tickets.