Skip to content

Commit eecf51d

Browse files
committed
whitespace gets removed from rowspan/colspan attributes when using rowSpan/colSpan properties
1 parent a5d345b commit eecf51d

4 files changed

Lines changed: 51 additions & 2 deletions

File tree

src/changes/changes.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
Jetty 9 websocket-client.
1919
</action>
2020

21+
<action type="fix" dev="Lai Quang Duong">
22+
Whitespace gets removed from rowspan/colspan attributes when using rowSpan/colSpan properties.
23+
</action>
2124
<action type="fix" dev="Lai Quang Duong">
2225
Restore the ability to specify null as password value (regression in 3.4.0).
2326
</action>

src/main/java/org/htmlunit/html/HtmlTableCell.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
* @author <a href="mailto:cse@dynabean.de">Christian Sell</a>
2828
* @author Ahmed Ashour
2929
* @author Frank Danek
30+
* @author Lai Quang Duong
3031
* @see HtmlTableDataCell
3132
* @see HtmlTableHeaderCell
3233
*/

src/main/java/org/htmlunit/javascript/host/html/HTMLTableCellElement.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
* @author Daniel Gredler
3939
* @author Ronald Brill
4040
* @author Frank Danek
41+
* @author Lai Quang Duong
4142
*/
4243
@JsxClass(domClass = HtmlTableCell.class)
4344
public class HTMLTableCellElement extends HTMLTableComponent {
@@ -178,7 +179,7 @@ public void setBgColor(final String bgColor) {
178179
*/
179180
@JsxGetter
180181
public int getColSpan() {
181-
final String s = StringUtils.replaceChars(getDomNodeOrDie().getAttribute("colSpan"), "\r\n", null);
182+
final String s = StringUtils.replaceChars(getDomNodeOrDie().getAttribute("colSpan"), "\r\n\t ", null);
182183
try {
183184
return Integer.parseInt(s);
184185
}
@@ -211,7 +212,7 @@ public void setColSpan(final String colSpan) {
211212
*/
212213
@JsxGetter
213214
public int getRowSpan() {
214-
final String s = StringUtils.replaceChars(getDomNodeOrDie().getAttribute("rowSpan"), "\r\n", null);
215+
final String s = StringUtils.replaceChars(getDomNodeOrDie().getAttribute("rowSpan"), "\r\n\t ", null);
215216
try {
216217
return Integer.parseInt(s);
217218
}

src/test/java/org/htmlunit/javascript/host/html/HTMLTableCellElementTest.java

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,28 @@ public void colSpan() throws Exception {
328328
loadPageVerifyTitle2(html);
329329
}
330330

331+
/**
332+
* @throws Exception if an error occurs
333+
*/
334+
@Test
335+
@Alerts("3")
336+
public void colSpanLineBreaks() throws Exception {
337+
final String html
338+
= "<html><body><table>\n"
339+
+ " <tr>\n"
340+
+ " <td id='td1' colspan='\r3\t\n '>b</td>\n"
341+
+ " </tr>\n"
342+
+ "</table>\n"
343+
+ "<script>\n"
344+
+ LOG_TITLE_FUNCTION_NORMALIZE
345+
+ " var td1 = document.getElementById('td1');\n"
346+
+ " log(td1.colSpan);\n"
347+
+ "</script>\n"
348+
+ "</body></html>";
349+
350+
loadPageVerifyTitle2(html);
351+
}
352+
331353
/**
332354
* @throws Exception if an error occurs
333355
*/
@@ -382,6 +404,28 @@ public void rowSpan() throws Exception {
382404
loadPageVerifyTitle2(html);
383405
}
384406

407+
/**
408+
* @throws Exception if an error occurs
409+
*/
410+
@Test
411+
@Alerts("3")
412+
public void rowSpanLineBreaks() throws Exception {
413+
final String html
414+
= "<html><body><table>\n"
415+
+ " <tr>\n"
416+
+ " <td id='td1' rowspan='\r3\t\n '>a</td>\n"
417+
+ " </tr>\n"
418+
+ "</table>\n"
419+
+ "<script>\n"
420+
+ LOG_TITLE_FUNCTION_NORMALIZE
421+
+ " var td1 = document.getElementById('td1');\n"
422+
+ " log(td1.rowSpan);\n"
423+
+ "</script>\n"
424+
+ "</body></html>";
425+
426+
loadPageVerifyTitle2(html);
427+
}
428+
385429
/**
386430
* @throws Exception if an error occurs
387431
*/

0 commit comments

Comments
 (0)