#9602 closed bug (duplicate)
Exception when adding a new node in XML.
Reported by: | rcrathore | Owned by: | rcrathore |
---|---|---|---|
Priority: | low | Milestone: | 1.next |
Component: | manipulation | Version: | 1.6.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
jsFiddle URL : http://jsfiddle.net/rcrathore/Y8DpM/[1]
I am trying to add a new node in XML using jQuery. Following code works fine in Firefox, Safari and Chrome but giving error in IE8:
<div id="result"> </div>
<div id="result2"> </div>
<script type="text/javascript"> <!--
var xml = "<root><node1><node2>TEXT1</node2></node1></root>" ; var $xml = $($.parseXML(xml)) ;
var newData = "<node3>234</node3>" ; var $newData = $($.parseXML(newData)); var newNode = null;
if (typeof document.importNode == 'function') {
newNode = document.importNode($newData.find('node3').get(0),true);
} else {
newNode = $newData.find('node3').get(0)
}
try {
$(newNode).appendTo($xml.find("node2")); /* expected TEXT1234*/ $("div#result").html($xml.text());
/* expected 234*/ $("div#result2").html($xml.find("root > node1 > node2 > node3").text());
} catch (e) {
alert(e) ; $("div#result").html("Error: " + e.description);
}
--> </script>
The error description on IE8 is "Wrong number of arguments or invalid property assignment".
Change History (8)
comment:1 Changed 12 years ago by
comment:2 Changed 12 years ago by
Related?
//Crash in IE var $xml = $('<xml />').append($('<root />').append('<child />'));
//Works in IE var $xml = $('<exml />').append($('<root />').append('<child />'));
comment:3 Changed 12 years ago by
Component: | unfiled → manipulation |
---|---|
Owner: | set to rcrathore |
Priority: | undecided → low |
Status: | new → pending |
Thanks for taking the time to contribute to the jQuery project! Please provide a reduced test case on http://jsfiddle.net that reproduces the issue experienced to help us assess your ticket.
Additionally, test against the jQuery (edge) version to ensure the issue still exists.
comment:4 Changed 12 years ago by
Status: | pending → new |
---|
Isaac, timmywil:
- Not sure if Isaac's example is related.
- Not sure what can be reduced in my test case. I think it is already very compact. A root element has node2 and node2 and I am inserting a new node (node3) under node2.
- I will test it with jQuery (edge) version and update this case.
comment:5 Changed 12 years ago by
Duplicate of #9370. Fixed at 1d1cb582c0f744afaa51a63d374b9ffe0f58d1db
comment:7 Changed 12 years ago by
Resolution: | → duplicate |
---|---|
Status: | new → closed |
The code works in all browsers if I replace appendTo line
by :