Skip to main content

Bug Tracker

Side navigation

#13592 closed bug (notabug)

Opened March 11, 2013 08:09AM UTC

Closed March 12, 2013 04:50PM UTC

Corrupt column text when create TD with more than 2 html tags

Reported by: anonymous Owned by: anonymous
Priority: undecided Milestone: None
Component: unfiled Version: 1.9.1
Keywords: Cc:
Blocked by: Blocking:
Description

When add TD that contain more than 2 html tags, the TD content was corrupted. The first column in first row which include 2 tags (span and A)

is display correctly. But when I add <br /> tag to the second row, the

TD content was corrupted

In the example.

--HTML--

<!DOCTYPE html PUBLIC "-W3CDTD HTML 4.01 TransitionalEN" "http:www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

<title>Insert title here</title>

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

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

</head>

<body>

<table border="1" id="a">

</table>

<table style="display:none">

<tr id ="tpl_row">

<td><a href="#">Col1</a></td>

<td> Col2 </td>

</tr>

</table>

</body>

</html>

--HTML--

--JS--

$(document).ready(document_ready);

function document_ready()

{

var tbl = $("#a");

var row_tpl = $("#tpl_row");

var rows = [

["<span>Row1<span><A href=\\"#\\">Link1</A>","Ok"],

["<span>Row2<span><br/><A href=\\"#\\">Link2</A>","Error"],

];

for(var i in rows)

{

var row = row_tpl.clone();

for(var k = 0; k <2; ++k)

{

row.find(":nth-child(" + (k+1) + ")").html(rows[i][k]);

}

tbl.append(row);

}

}

Attachments (0)
Change History (4)

Changed March 11, 2013 01:36PM UTC by timmywil comment:1

owner: → anonymous
status: newpending

Thanks for taking the time to contribute to the jQuery project! Please provide a complete reduced test case on jsFiddle to help us assess your ticket.

Additionally, be sure to test against the jQuery Edge version to ensure the issue still exists. To get you started, use this boilerplate: http://jsfiddle.net/FrKyN/. Open the link and click to "Fork" (in the top menu) to get started.

Changed March 11, 2013 01:58PM UTC by scottgonzalez comment:2

Also, make sure to test with a doctype that will trigger standards mode; 4.01 Transitional with a system identifier triggers different modes in different browsers.

Changed March 12, 2013 04:29PM UTC by anonymous comment:3

status: pendingnew

Just add the test case to jsFiddle.

http://jsfiddle.net/FrKyN/565/

Changed March 12, 2013 04:50PM UTC by dmethvin comment:4

resolution: → notabug
status: newclosed

You're cloning an element with an ID, then reinjecting multiple copies into the document, creating an invalid document. Work out these issues with some helpful people on a forum and only file a bug when you've established there is a jQuery bug.