开发者

JEditorPane is discarding empty elements

开发者 https://www.devze.com 2022-12-31 09:08 出处:网络
The following test fails with JRE 1.6.0_20 public void testSetGetTextWithList() throws Exception { final JEditorPane editorPane = new JEditorPane();

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>&nbsp;
<ul><li></li></ul><!---->
0

精彩评论

暂无评论...
验证码 换一张
取 消