Bug Tracker

Opened 15 years ago

Closed 15 years ago

Last modified 11 years ago

#1902 closed bug (invalid)

jQuery.append mixed content gets mixed up

Reported by: grosensteel Owned by:
Priority: major Milestone: 1.2.2
Component: core Version: 1.2.1
Keywords: Cc: [email protected]
Blocked by: Blocking:


When adding mixed xml and html content to an element in the DOM, the XML and HTML code gets separated out of order.

This code demonstrates the problem:

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">


<script type="text/javascript" src="../../js/lib/jquery.js"></script>



var vars = $("#variables");

alert('vars before: ' + vars.html());

vars.append("<foo><p>this is p tag content inside the foo tag</p></foo>");

alert('vars after: ' + vars.html()); notice the output of this alert is that the p tag appears after the foo tag. Should appear inside it





<div id="variables"></div>



Change History (2)

comment:1 Changed 15 years ago by joern

I'm not sure what the foo-tag is to the HTML parser, but what may happen here is the usual tagsoup behaviour when a block element nested inside an inline element: The parser just closes the inline element and puts the block element (the p) after it. In that case there'd be nothing jQuery could do about it, you just need to fix your code.

Anyone else?

comment:2 Changed 15 years ago by brandon

Resolution: invalid
Status: newclosed

Agreed. Invalid HTML is unpredictable.

Note: See TracTickets for help on using tickets.