Menu

#1069 DomElement#getElementsByTagName differs from actual browsers

Latest SVN
closed
None
5
2012-10-21
2010-04-13
luniki
No

In every browser I tested the following works:

doc.getElementsByTagName("namespace:element")

HTMLUnit cannot find this, as its implementation:

388 public DomNodeList<htmlelement> getElementsByTagName(final String tagName) {
389 return new XPathDomNodeList<htmlelement>(this, ".//*[local-name()='" + tagName + "']");
390 }</htmlelement></htmlelement>

is wrong. Replacing "local-name()" with "name()" corrects this problem.

Discussion

  • Ahmed Ashour

    Ahmed Ashour - 2010-04-13

    Can you provide a minimal html/js case that works differently?

     
  • luniki

    luniki - 2010-04-13

    Sure:

    <namespace:element> </namespace:element> <script> var elements = document.getElementsByTagName("namespace:element"); document.write(elements.length === 1 ? "pass" : "fail"); </script>
     
  • Ahmed Ashour

    Ahmed Ashour - 2010-04-13

    This test is valid for FF, but not for IE

     
  • luniki

    luniki - 2010-04-19

    You are right: There are two sets of Browsers.

    In every MSIE (and derivates) document.getElementsByTagName("element") works and document.getElementsByTagName("namespace:element") does not.

    In every other browser document.getElementsByTagName("element") does not work and document.getElementsByTagName("namespace:element") does.

    I checked this with all browsers of http://browsershots.org .

     
  • Ahmed Ashour

    Ahmed Ashour - 2010-04-28

    Thanks for reporting, fixed in SVN

     

Log in to post a comment.

MongoDB Logo MongoDB