Bug Tracker

Ticket #4509 (closed bug: invalid)

Opened 6 years ago

Last modified 3 years ago

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:
Blocking: Blocked by:

Description

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

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

Change History

Changed 6 years ago by Vic D'Elfant

Proof of Concept

comment:1 Changed 6 years ago by dmethvin

  • Status changed from new to closed
  • Resolution set to invalid

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.

 http://blogs.msdn.com/ie/archive/2005/09/15/467901.aspx

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.