Skip to main content

Bug Tracker

Side navigation

#9960 closed bug (fixed)

Opened August 03, 2011 01:26PM UTC

Closed November 24, 2012 09:54PM UTC

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

Reported by: FranPregernik@googlemail.com Owned by: coopersemantics
Priority: low Milestone: 1.next
Component: manipulation Version: 1.6.2
Keywords: Cc:
Blocked by: Blocking:
Description

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.

Attachments (0)
Change History (10)

Changed August 03, 2011 01:29PM UTC by FranPregernik@googlemail.com comment:1

Tested on:

Chrome 13, Firefox 5, IE9

Changed August 03, 2011 02:21PM UTC by dmethvin comment:2

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!

Changed August 03, 2011 02:43PM UTC by dmethvin comment:3

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.

Changed August 04, 2011 09:02AM UTC by FranPregernik comment:4

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

Changed October 13, 2011 04:13AM UTC by dmethvin comment:5

component: unfiledmanipulation
milestone: None1.next
priority: undecidedlow

Changed January 31, 2012 02:23PM UTC by sindresorhus comment:6

#11169 is a duplicate of this ticket.

Changed September 05, 2012 02:31AM UTC by mikesherov comment:7

owner: → mikesherov
status: openassigned

Changed September 07, 2012 05:22PM UTC by mikesherov comment:8

owner: mikesherovcoopersemantics

Changed September 07, 2012 06:16PM UTC by coopersemantics comment:9

Changed November 24, 2012 09:54PM UTC by dcooper comment:10

resolution: → fixed
status: assignedclosed

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

Changeset: 78c1560065e664213ac0cbea7518d442a58b0018