Sometimes I just simply need to know if an element I've found is a heading element regardless of the level (1-6). Can HtmlHeading1-HtmlHeading6 implement/extend a common interface/class (e.g. HtmlHeading).
Imagine you are using a TreeWalker and you want to switch off of whether an element is a heading element or not. In JavaScript, I would just check to see if node instanceof HTMLHeadingElement but in HtmlUnit I have to check against 6 different tag names or class types. :-(
If HtmlHeading1-HtmlHeading6 all extended/implemented an HtmlHeading then I would only need to check against one instance type. I guess it is more of a convenience thing than anything else. I can live without it; I just thought it would be a nice addition.
Thanks.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I don't see much value for another class, since there is no header-specific logic to be extracted.
You can use .getTagName() to know if it is a heading element.
Imagine you are using a
TreeWalkerand you want to switch off of whether an element is a heading element or not. In JavaScript, I would just check to see ifnode instanceof HTMLHeadingElementbut in HtmlUnit I have to check against 6 different tag names or class types. :-(If
HtmlHeading1-HtmlHeading6all extended/implemented anHtmlHeadingthen I would only need to check against one instance type. I guess it is more of a convenience thing than anything else. I can live without it; I just thought it would be a nice addition.Thanks.