Bug 83602

Summary: Unspecified DOM attributes without defaults not DOM Level 2 compliant
Product: [Applications] konqueror Reporter: Unknown <null>
Component: khtml ecmaAssignee: Konqueror Developers <konq-bugs>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: RedHat Enterprise Linux   
OS: Linux   
Latest Commit: Version Fixed In:

Description Unknown 2004-06-18 18:28:18 UTC
Version:           3.2.2-4 (using KDE KDE 3.2.2)
Installed from:    RedHat RPMs
OS:                Linux

The DOM Level 2 HTML specification says:  "The return value of an attribute that is unspecified and does not have a default value is the empty string if the return type is a DOMString, false if the return type is a boolean and 0 if the return type is a number."
http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-642250288

Konqueror is not compliant, and does return null instead of the empty string for example in the following:
<a href="#" onclick="alert(this.className);return false">test</a>
Comment 1 Unknown 2004-06-18 18:31:31 UTC
Forgot to add that the getAttribute() method in Konq is DOM compliant, it does return the empty string for nonexisting attributes.  It's the "property attributes" which have this bug.
Comment 2 Yan Morin 2004-10-11 01:26:05 UTC
In this file:
http://webcvs.kde.org/cgi-bin/cvsweb.cgi/kdelibs/khtml/ecma/kjs_html.cpp?rev=1.272

Change:
  case ElementLang:
    return getString(element.lang());
  case ElementDir:
    return getString(element.dir());
  case ElementClassName:
    return getString(element.className());

to this:
  case ElementLang:
    return String(element.lang());
  case ElementDir:
    return String(element.dir());
  case ElementClassName:
    return String(element.className());
Comment 3 Harri Porten 2004-10-11 13:23:59 UTC
We we discussing this issue for quite a while already. Thanks for the pointer
to the spec. Fixed in CVS HEAD now.