-
Task
-
Resolution: Fixed
-
P4
-
None
-
b23
The `Content.isValid()` method is currently used to detect empty HtmlTree instances that should not be added in `HtmlTree.add(Content)`. This is not a great solution for a few reasons:
- Content that is generated and added is silently dropped
- The implementation of `isValid()` is quite specific for various HTML elements, making it hard to understand
- Content also has an `isEmpty()` method which in the default implementation is sometimes but not always the logical negation of `isValid()`
- There are times when we do want to add "invalid" content, for which there is the HtmlTree.EMPTY sentinel value (seeJDK-8267394)
We should try to find a solution to these problems that is simpler and is less prone to surprising behavior.
- Content that is generated and added is silently dropped
- The implementation of `isValid()` is quite specific for various HTML elements, making it hard to understand
- Content also has an `isEmpty()` method which in the default implementation is sometimes but not always the logical negation of `isValid()`
- There are times when we do want to add "invalid" content, for which there is the HtmlTree.EMPTY sentinel value (see
We should try to find a solution to these problems that is simpler and is less prone to surprising behavior.