8247235: doclint should permit "self-closing" tags for void elements in HTML5
Reviewed-by: hannesw
This commit is contained in:
parent
52be8949e7
commit
e3cb4df4ef
@ -375,7 +375,7 @@ public class Checker extends DocTreePathScanner<Void, Void> {
|
||||
}
|
||||
|
||||
// check for self closing tags, such as <a id="name"/>
|
||||
if (tree.isSelfClosing()) {
|
||||
if (tree.isSelfClosing() && !isSelfClosingAllowed(t)) {
|
||||
env.messages.error(HTML, tree, "dc.tag.self.closing", treeName);
|
||||
}
|
||||
|
||||
@ -415,6 +415,13 @@ public class Checker extends DocTreePathScanner<Void, Void> {
|
||||
}
|
||||
}
|
||||
|
||||
// so-called "self-closing" tags are only permitted in HTML 5, for void elements
|
||||
// https://html.spec.whatwg.org/multipage/syntax.html#start-tags
|
||||
private boolean isSelfClosingAllowed(HtmlTag tag) {
|
||||
return env.htmlVersion == HtmlVersion.HTML5
|
||||
&& tag.endKind == HtmlTag.EndKind.NONE;
|
||||
}
|
||||
|
||||
private void checkStructure(StartElementTree tree, HtmlTag t) {
|
||||
Name treeName = tree.getName();
|
||||
TagStackItem top = tagStack.peek();
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 4515705 4804296 4702454 4697036 8025633 8182765
|
||||
* @bug 4515705 4804296 4702454 4697036 8025633 8182765 8247235
|
||||
* @summary Make sure that first sentence warning only appears once.
|
||||
* Make sure that only warnings/errors are printed when quiet is used.
|
||||
* Make sure that links to private/unincluded methods do not cause
|
||||
@ -50,18 +50,24 @@ public class TestWarnings extends JavadocTester {
|
||||
"pkg");
|
||||
checkExit(Exit.ERROR);
|
||||
|
||||
checkOutput(Output.OUT, true,
|
||||
checkOutput(Output.OUT, false,
|
||||
"X.java:23: error: self-closing element not allowed");
|
||||
|
||||
checkOutput(Output.OUT, true,
|
||||
checkOutput(Output.OUT, false,
|
||||
"X.java:24: error: self-closing element not allowed");
|
||||
|
||||
checkOutput(Output.OUT, true,
|
||||
checkOutput(Output.OUT, false,
|
||||
"X.java:25: error: self-closing element not allowed");
|
||||
|
||||
checkOutput(Output.OUT, true,
|
||||
checkOutput(Output.OUT, false,
|
||||
"X.java:26: error: self-closing element not allowed");
|
||||
|
||||
checkOutput(Output.OUT, true,
|
||||
"X.java:28: error: self-closing element not allowed");
|
||||
|
||||
checkOutput(Output.OUT, true,
|
||||
"X.java:28: warning: empty <p> tag");
|
||||
|
||||
checkOutput("pkg/X.html", false,
|
||||
"can't find m()");
|
||||
checkOutput("pkg/X.html", false,
|
||||
|
@ -24,6 +24,8 @@ public class X implements Serializable {
|
||||
* {@link #m()}<br/>
|
||||
* {@link #f}<br/>
|
||||
* {@link java.lang.String#toString()}<br/>
|
||||
* <hr/>
|
||||
* <p/>
|
||||
*/
|
||||
public void foo() {}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user