Bug 97185 - [TESTCASE] ECMA function doesn't work with KHTML
Summary: [TESTCASE] ECMA function doesn't work with KHTML
Status: RESOLVED FIXED
Alias: None
Product: konqueror
Classification: Applications
Component: khtml ecma (show other bugs)
Version: SVN
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Konqueror Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-01-16 21:55 UTC by George Staikos
Modified: 2005-01-17 21:24 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
Testcase (513 bytes, text/html)
2005-01-16 21:55 UTC, George Staikos
Details

Note You need to log in before you can comment on or make changes to this bug.
Description George Staikos 2005-01-16 21:55:28 UTC
This was reduced from aeroplan.com when trying to book a flight.  This may not 
be the only problem, but it is rather major so I had to hack around it 
manually.  This function doesn't seem to work in KHTML the way the site 
expects it to: 
 
function interrogate(what) { 
for(var i in what) { 
   if (i == "length") { 
     return true; 
   } 
} 
return false; 
} 
 
when called with a radio button group from a form.  Testcase attached.
Comment 1 George Staikos 2005-01-16 21:55:56 UTC
Created attachment 9120 [details]
Testcase
Comment 2 George Staikos 2005-01-17 09:36:58 UTC
Confirmed that this works with IE6.
Comment 3 David Faure 2005-01-17 21:24:54 UTC
CVS commit by faure: 

DOMNamedNodesCollection: fixed 'length' not available during enumerating, like "for (var i in what)"
BUG: 97185


  M +12 -8     kjs_dom.cpp   1.183
  M +2 -1      kjs_dom.h   1.73


--- kdelibs/khtml/ecma/kjs_dom.cpp  #1.182:1.183
@@ -1211,4 +1211,7 @@ Value DOMDocumentType::getValueProperty(
   removeNamedItemNS     DOMNamedNodeMap::RemoveNamedItemNS      DontDelete|Function 2
 @end
+@begin DOMNamedNodeMapTable 7
+  length                DOMNamedNodeMap::Length                 DontDelete|Function 1
+@end
 */
 DEFINE_PROTOTYPE("NamedNodeMap", DOMNamedNodeMapProto)
@@ -1216,5 +1219,5 @@ IMPLEMENT_PROTOFUNC_DOM(DOMNamedNodeMapP
 IMPLEMENT_PROTOTYPE(DOMNamedNodeMapProto,DOMNamedNodeMapProtoFunc)
 
-const ClassInfo DOMNamedNodeMap::info = { "NamedNodeMap", 0, 0, 0 };
+const ClassInfo DOMNamedNodeMap::info = { "NamedNodeMap", 0, &DOMNamedNodeMapTable, 0 };
 
 DOMNamedNodeMap::DOMNamedNodeMap(ExecState *exec, const DOM::NamedNodeMap& m)
@@ -1226,10 +1229,6 @@ DOMNamedNodeMap::~DOMNamedNodeMap()
 }
 
-// We have to implement hasProperty since we don't use a hashtable for 'length'
-// ## this breaks "for (..in..)" though.
 bool DOMNamedNodeMap::hasProperty(ExecState *exec, const Identifier &p) const
 {
-  if (p == lengthPropertyName)
-    return true;
   // ## missing? array index
   return DOMObject::hasProperty(exec, p);
@@ -1620,5 +1619,10 @@ Object KJS::getDOMExceptionConstructor(E
 // -------------------------------------------------------------------------
 
-const ClassInfo KJS::DOMNamedNodesCollection::info = { "DOMNamedNodesCollection", 0, 0, 0 };
+/* Source for DOMNamedNodesCollection.
+@begin DOMNamedNodesCollectionTable 1
+  length                KJS::DOMNamedNodesCollection::Length            DontDelete|ReadOnly
+@end
+*/
+const ClassInfo KJS::DOMNamedNodesCollection::info = { "DOMNamedNodesCollection", 0, &DOMNamedNodesCollectionTable, 0 };
 
 // Such a collection is usually very short-lived, it only exists

--- kdelibs/khtml/ecma/kjs_dom.h  #1.72:1.73
@@ -182,5 +182,5 @@ namespace KJS {
     virtual bool toBoolean(ExecState *) const { return true; }
     static const ClassInfo info;
-    enum { GetNamedItem, SetNamedItem, RemoveNamedItem, Item,
+    enum { GetNamedItem, SetNamedItem, RemoveNamedItem, Item, Length,
            GetNamedItemNS, SetNamedItemNS, RemoveNamedItemNS };
     DOM::NamedNodeMap toMap() const { return map; }
@@ -261,4 +261,5 @@ namespace KJS {
     static const ClassInfo info;
     const QValueList<DOM::Node>& nodes() const { return m_nodes; }
+    enum { Length };
   private:
     QValueList<DOM::Node> m_nodes;