Menu ▾ ▴

#242 Add HtmlHeading class/interface

2.24
wont-fix
None
1
2017-01-11
2017-01-10
Mark Fulton
No

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).

Discussion

  • Ahmed Ashour

    Ahmed Ashour - 2017-01-11
    • status: open --> wont-fix
    • assigned_to: Ahmed Ashour
     
  • Ahmed Ashour

    Ahmed Ashour - 2017-01-11

    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.

     
  • Mark Fulton

    Mark Fulton - 2017-01-11

    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.

     

Log in to post a comment.