Test scenario is for HtmlPage.asText(), using the HTML code below. Browsers render this HTML displaying all DIVs in the source, rendering the ordered lists identical to the unordered lists, but with numbers.
Summary: The ordered list serializer (appendHtmlOrderedList) is overly restrictive in that it only appends children of type HtmlListItem:
if (!(item instanceof HtmlListItem)) {
continue;
}
The UNordered list handler (appendHtmlUnorderedList) succeessfully simulates the browsers, as it uses appendNode to include all child nodes.
Suggested: While maintaining the nice auto-numbering already present, we could merge the two techniques. Auto-number the List Items but also include other nodes in proper order:
// Remove the "if not HtmlListItem continue" block
// Wrap the "doAppend / appendChildren with a new if/else
if(item instanceof HtmlListItem) {
doAppend(Integer.toString(i++));
doAppend(". ");
appendChildren(item);
}
else {
appendNode(item);
}
Here's the test HTML. The current serializer will skip over the DIVs in the ordered list examples. A successful update will render all 3 lines for each example, making the ordered list just like the unordered list (but with numbering).
<html><body>
<h3>Working Properly: Mixed Unordered list</h3>
<ul>
<li>List Item 1</li>
<div>div inside list 1</div>
<li>List Item 2</li>
</ul>
<h3>Working Properly: Unordered list with only divs</h3>
<ul>
<div>div 1</div>
<div>div 2</div>
<div>div 3</div>
</ul>
<h3>Fail: Mixed Ordered list - there should be 1 div visible</h3>
<ol>
<li>List Item 1</li>
<div>div inside list 1</div>
<li>List Item 2</li>
</ol>
<h3>Fail: Ordered list with only divs - there should be 3 divs visible</h3>
<ol>
<div>div 1</div>
<div>div 2</div>
<div>div 3</div>
</ol>
</body></html>
Fixed in svn, thaks for the report.