RFR: JDK-8266856 Make <wbr> element void

Pavel Rappo prappo at openjdk.java.net
Wed May 19 09:56:40 UTC 2021


On Tue, 18 May 2021 23:48:14 GMT, Jonathan Gibbons <jjg at openjdk.org> wrote:

> I'm not sure I completely understand your question.

I would like to have a mechanism to guard us from inconsistencies like this, is all. Consider adding something like the below white-box test.

<details>
<summary>Test</summary>


import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
import jdk.javadoc.internal.doclets.formats.html.markup.TagName;
import jdk.javadoc.internal.doclint.HtmlTag;

/*
 * @test
 * @bug 8266856
 * @modules jdk.javadoc/jdk.javadoc.internal.doclint
 *          jdk.javadoc/jdk.javadoc.internal.doclets.formats.html.markup
 * @run main TestVoidHtmlElements
 */
public class TestVoidHtmlElements {

    public static void main(String[] args) {
        int checks = 0;
        for (HtmlTag htmlTag : HtmlTag.values()) {
            TagName tagName = tagNameOf(htmlTag);
            if (tagName == null) {
                continue;
            }
            checks++;
            boolean elementIsVoid = new HtmlTree(tagName).isVoid();
            boolean elementHasNoEndTag = htmlTag.endKind == HtmlTag.EndKind.NONE;
            if (elementIsVoid != elementHasNoEndTag) {
                throw new AssertionError(htmlTag + ", " + elementIsVoid + ", " + elementHasNoEndTag);
            }
        }
        if (checks == 0) { // suspicious
            throw new AssertionError();
        }
    }

    private static TagName tagNameOf(HtmlTag htmlTag) {
        TagName tagName;
        try {
            tagName = TagName.valueOf(htmlTag.name()); // map HtmlTag to TagName
        } catch (IllegalArgumentException ignored) {
            return null;
        }
        return tagName;
    }
}


</details>

-------------

PR: https://git.openjdk.java.net/jdk/pull/4098


More information about the compiler-dev mailing list