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>
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.
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());
We we discussing this issue for quite a while already. Thanks for the pointer to the spec. Fixed in CVS HEAD now.