JEditorPane is discarding empty elements
The following test fails with JRE 1.6.0_20
public void testSetGetTextWithList() throws Exception {
final JEditorPane editorPane = new JEditorPane();
editorPane.setContentType("text/html");
editorPane.setText("<ul><li></li></ul>");
assertTrue(editorPane.getText().contains("<ul"));
}
Of course, there is a visual difference between an empty list and a non-existing list, so I expect the editor not to discard the emp开发者_Python百科ty list. Anybody with an easy solution for this problem?
The error occurs only if the element is the last block element in the document, the test passes if you change the input to one of
<ul><li></li></ul>a
<ul><li></li></ul><p></p>
<ul><li></li></ul>
<ul><li></li></ul><!---->
精彩评论