JEdi​​torPane正在丢弃空元素

时间:2010-05-21 07:28:29

标签: java html swing html-lists jeditorpane

以下测试因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"));
}

当然,空列表和不存在的列表之间存在视觉差异,因此我希望编辑器放弃空列表。任何人都可以轻松解决这个问题吗?

1 个答案:

答案 0 :(得分:1)

仅当元素是文档中的 last 块元素时才会发生错误,如果将输入更改为

之一,则测试通过
<ul><li></li></ul>a
<ul><li></li></ul><p></p>
<ul><li></li></ul>&nbsp;
<ul><li></li></ul><!---->