Bug Tracker

Opened 14 years ago

Closed 14 years ago

Last modified 11 years ago

#4509 closed bug (invalid)

jQuery removing slash from self-closing tag

Reported by: Vic D'Elfant Owned by:
Priority: major Milestone: 1.4
Component: unfiled Version: 1.3.2
Keywords: Cc:
Blocked by: Blocking:


By accident, I found out that jQuery appears to be removing the closing slash from a self-closing XHTML tag when inserting this tag through .append(), .prepend() and other ways, which results in invalid XHTML which - on its turn - results in mangled markup.

The following code, for example:

$('body').append('<input type="hidden" name="test" value="test" />');

Results in the following:

<input name="test" value="test" type="hidden">

Whilst the expected output is:

<input name="test" value="test" type="hidden" />

Please see the attached file for a working POC.

Attachments (1)

jquery-bug-poc.htm (591 bytes) - added by Vic D'Elfant 14 years ago.
Proof of Concept

Download all attachments as: .zip

Change History (2)

Changed 14 years ago by Vic D'Elfant

Attachment: jquery-bug-poc.htm added

Proof of Concept

comment:1 Changed 14 years ago by dmethvin

Resolution: invalid
Status: newclosed

Since this seems to work fine in Firefox3, I am going to assume you saw this in IE. Internet Explorer does not understand XHTML so it is treating your markup as HTML and trying to fix the invalid markup in the parser.


If it's happening on other browsers that do support XHTML, be sure that you're serving the page as application/xml+xhtml.

Note: See TracTickets for help on using tickets.