Version: 3.5.2 (using KDE KDE 3.5.2) Installed from: Ubuntu Packages OS: Linux The call typeof( self.document.forms ) returns "function", but self.document.forms also has a "length" property. I don't think of functions as having member properties. No other browser thinks this property is a function. In other browsers, this call returns "object" (that has a "length" property and an item() method). One could also imagine calling it an "array". But I think "function" is not appropriate. Other examples in self.document. all anchors images applets links layers styleSheets childNodes It looks as if everything I would think of as a list or array is reported as a function. This happens throughout the object tree, not just in document.
All functions in core JS have properties, in particular .length, actually. (Which does mean a different thing then for collections --- it's the minimum number of "required" arguments, actually) The reason these are reported as functions is that they can be called as such, IIRC, I think document.forms(1) works as well if my memory serves me right. Anyway, is there a practical problem this is causing?
Yes, it has caused a problem. I can confirm that self.properties.forms(0) gives the same result as the array form in Konqueror, but not in Firefox. That's fine with me, but real-world code is written to support the traditional structures. Since Konqueror supports the traditional structures as well, it would be better that it advertized them as such as well. I looked in the DOM specs on this, and it isn't clear to me. There it says these are read-only properties. This might mean, I suppose, that they are accessed via a function call. But I would prefer that the browser used "function" for methods of the DOM, and "object" "string" "number" for properties. But generally, would be better if Konqueror behaved like the other browsers in this respect. Otherwise, we have to write browser-specific code, and spend hours freetting over little things.
I don't think there is any written standard about this. By the ECMAScript standard these objects would count as functions but they are "DOM 0" hacks not following any rule. But I agree that it would be wise to follow what others are doing for the sake of portability.
SVN commit 846672 by orlovich: Add support for making typeof() of calleable things not be "function" but "object" in KJS, and use it for the array-like things that support the IE call notation in KHTML. (Actually, one is still unchanged, but I am in process of removing it) BUG: 139981 M +1 -0 khtml/ecma/kjs_css.h M +1 -0 khtml/ecma/kjs_dom.h M +1 -0 khtml/ecma/kjs_html.h M +1 -1 kjs/bytecode/machine.cpp.in M +5 -0 kjs/object.cpp M +10 -0 kjs/object.h WebSVN link: http://websvn.kde.org/?view=rev&revision=846672
SVN commit 846675 by orlovich: Regression test for #139981 CCBUG:139981 A baseline/dom/typeof-arraylike.html-dom AM baseline/dom/typeof-arraylike.html-dump.png A baseline/dom/typeof-arraylike.html-render A tests/dom/typeof-arraylike.html WebSVN link: http://websvn.kde.org/?view=rev&revision=846675