JEdi​​torPane 正在丢弃空元素

发布于 2024-09-03 03:12:26 字数 410 浏览 2 评论 0原文

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

当然,空列表和不存在的列表之间存在视觉差异,因此我希望编辑器不会丢弃空列表。有人可以简单地解决这个问题吗?

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 empty list. Anybody with an easy solution for this problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

童话里做英雄 2024-09-10 03:12:26

仅当该元素是文档中的最后一个块元素时才会发生错误,如果将输入更改为以下之一,则测试通过

<ul><li></li></ul>a
<ul><li></li></ul><p></p>
<ul><li></li></ul> 
<ul><li></li></ul><!---->

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><!---->
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文