On Tue, 8 Feb 2022 17:06:03 GMT, Jonathan Gibbons <j...@openjdk.org> wrote:

> > A few remarks about the rewritten HtmlTree.isEmpty() method: its purpose is 
> > to determine whether content is missing in an element that should have 
> > content. It therefore always returns false for elements that are expected 
> > or allowed to be without content. This is maybe a bit counter-intuitive, 
> > but it is what is needed. We could do a combined check such as isVoid() || 
> > !isEmpty() but that would still leave out elements that can be empty, such 
> > as <script>.
> 
> I agree the current situation is not great, and needs revision, so thanks for 
> taking this on.
> 
> While it may be hard to completely remove the creation and use of empty 
> elements, we should at least try and reduce the number. The current state is 
> a hangover from very-old javadoc, which used print-to-stream before even 
> `HtmlTree`.
> 
> Having `isEmpty` return true for some empty elements is definitely 
> counter-intuitive and suggests the name is wrong. This seems better suited 
> for `isValid` with a definition involving `isVoid` and `isEmpty` as you 
> suggested. I don't quite understanding the comment about `<script>`. Maybe 
> you are wanting a way to mark elements which should not be considered empty, 
> as in "this space intentionally left blank". IIRC, that was the original 
> purpose of `HtmlTree.EMPTY` so perhaps some sort of marker element can stay, 
> perhaps with a better name, to mark HTML elements which should not be marked 
> invalid because they appear to be empty.

Related, maybe `isEmpty`, `isVoid` and `isValid` **all** have a place here, 
with well-defined semantics.

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

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

Reply via email to