Bug Tracker

Opened 11 years ago

Closed 11 years ago

Last modified 8 years ago

#4531 closed bug (invalid)

$("root", xmlData).append("<node />"); doesn't append anything

Reported by: fishbone Owned by:
Priority: major Milestone: 1.4
Component: unfiled Version: 1.3.2
Keywords: xml; modification Cc:
Blocked by: Blocking:

Description

if d is xmlData loaded with $.ajax,

doesn't work: $("data", d).append("<entry class='c' />");

works: $("data", d).append($("<entry class='d' />"));

tested with the available jQuery nightly downloaded 2009/04/13

Attachments (2)

main.html (819 bytes) - added by fishbone 11 years ago.
test.xml (151 bytes) - added by fishbone 11 years ago.

Download all attachments as: .zip

Change History (8)

Changed 11 years ago by fishbone

Attachment: main.html added

Changed 11 years ago by fishbone

Attachment: test.xml added

comment:1 Changed 11 years ago by fishbone

i found a similar problem: when traversing the children, none of the newly added entries will be shown:

function listEntries(target) {

$("data", d).children("entry").each(function() {

$("#entries").append("<p>"+$(this).attr("class")+"</p>");

});

}

comment:2 in reply to:  1 ; Changed 11 years ago by fishbone

Replying to fishbone:

i found a similar problem: when traversing the children, none of the newly added entries will be shown:

function listEntries(target) {

$("data", d).children("entry").each(function() {

$("#entries").append("<p>"+$(this).attr("class")+"</p>");

});

}

i noticed that .children() is case-sensitive traversing xml data. if you use .children("ENTRY") instead of .children("entry") it works. nevertheless i think it's a bug

comment:3 in reply to:  2 ; Changed 11 years ago by fishbone

it's because XML is case-sensitive. anyways it's a bug, because jQuery converts the string in append() to upper case.

comment:4 in reply to:  3 Changed 11 years ago by fishbone

sorry for bothering :) it isn't jQuery's bug. I tried it with element.appendChild(), and my lower case node name is converted into upper case

comment:5 in reply to:  description Changed 11 years ago by fishbone

jQuery uses a div element for initializing the DOM nodes of the respective selector. the data is appended in line 2275:

div.innerHTML = wrap[1] + elem + wrap[2];

the innerHTML property does the upper case conversion. This is "recommended" for html but invalid for xml data. a discussion about this "innerHTML" behaviour can be found here: http://www.developer-x.com/content/innerhtml/

comment:6 Changed 11 years ago by dmethvin

Resolution: invalid
Status: newclosed

All of jQuery's internal parsing treats the string as HTML, *not* XML; I've included links to the doc below. If you want to append unparsed XML content to an XML tree, parse it with an XML parser and pass the nodes to append() et al.

http://docs.jquery.com/Core/jQuery#htmlownerDocument

http://docs.jquery.com/Manipulation

Note: See TracTickets for help on using tickets.