Menu

#239 JavaScript getAttribute() should return null

Latest SVN
closed
None
5
2012-10-21
2005-03-06
No

In browsers, a JavaScript call to aDiv.getAttribute('title') when 'title'
isn't an attribute of aDiv returns null (see attached HTML file for an
example). HtmlUnit, however, returns an empty string ("") in this
scenario. Unfortunately, there seems to be many places in the
HtmlUnit code that throw NPEs when the result of the call to
HtmlElement#getAttributeValue() returns null (see
com.gargoylesoftware.htmlunit.javascript.host.Style, lines 165-166).

Discussion

  • George Murnock

    George Murnock - 2005-03-06

    Sample HTML file showing the browser returning null for a call to getAttribute() where the attribute isn't defined in the element.

     
  • Marc Guillemot

    Marc Guillemot - 2005-03-07

    Logged In: YES
    user_id=402164

    Fixed at js level HTMLElement.jsFunction_getAttribute.

     

Log in to post a comment.