[patch] JS NodeList object

Harri Porten porten at kde.org
Fri Mar 14 09:42:43 GMT 2008


Hi!

Most of the DOM classes are already accessible by name via JavaScript. The 
NodeList class is still missing and the attached patch is supposed to fix 
that. If someone sees anything wrong with it please speak up.

Harri.
-------------- next part --------------
Index: ecma/kjs_window.h
===================================================================
--- ecma/kjs_window.h	(revision 785391)
+++ ecma/kjs_window.h	(working copy)
@@ -139,7 +139,7 @@
     virtual const ClassInfo* classInfo() const { return &info; }
     static const ClassInfo info;
     enum { Closed, Crypto, DefaultStatus, Status, Document, Node, EventCtor, Range,
-           NodeFilter, DOMException, RangeException, CSSRule, Frames, _History, _External, Event, InnerHeight,
+           NodeFilter, NodeList, DOMException, RangeException, CSSRule, Frames, _History, _External, Event, InnerHeight,
            InnerWidth, Length, _Location, Navigate, Name, _Navigator, _Konqueror, ClientInformation,
            OffscreenBuffering, Opener, OuterHeight, OuterWidth, PageXOffset, PageYOffset,
            Parent, Personalbar, ScreenX, ScreenY, Scrollbars, Scroll, ScrollBy,
Index: ecma/kjs_dom.cpp
===================================================================
--- ecma/kjs_dom.cpp	(revision 785391)
+++ ecma/kjs_dom.cpp	(working copy)
@@ -681,6 +681,8 @@
 KJS_IMPLEMENT_PROTOFUNC(DOMNodeListProtoFunc)
 KJS_IMPLEMENT_PROTOTYPE("DOMNodeList",DOMNodeListProto,DOMNodeListProtoFunc)
 
+IMPLEMENT_PSEUDO_CONSTRUCTOR(NodeListPseudoCtor, "NodeList", DOMNodeListProto)
+
 const ClassInfo DOMNodeList::info = { "NodeList", 0, 0, 0 };
 
 DOMNodeList::DOMNodeList(ExecState *exec, DOM::NodeListImpl* l)
Index: ecma/kjs_window.cpp
===================================================================
--- ecma/kjs_window.cpp	(revision 785391)
+++ ecma/kjs_window.cpp	(working copy)
@@ -325,6 +325,7 @@
   Event		Window::EventCtor	DontDelete
   Range		Window::Range		DontDelete
   NodeFilter	Window::NodeFilter	DontDelete
+  NodeList	Window::NodeList	DontDelete
   DOMException	Window::DOMException	DontDelete
   RangeException Window::RangeException	DontDelete
   CSSRule	Window::CSSRule		DontDelete
@@ -772,6 +773,8 @@
       return getRangeConstructor(exec);
     case NodeFilter:
       return getNodeFilterConstructor(exec);
+    case NodeList:
+      return NodeListPseudoCtor::self(exec);
     case DOMException:
       return getDOMExceptionConstructor(exec);
     case RangeException:
Index: ecma/kjs_dom.h
===================================================================
--- ecma/kjs_dom.h	(revision 785391)
+++ ecma/kjs_dom.h	(working copy)
@@ -106,6 +106,8 @@
     static JSValue *lengthGetter(ExecState *, JSObject*, const Identifier&, const PropertySlot&);
   };
 
+  DEFINE_PSEUDO_CONSTRUCTOR(NodeListPseudoCtor)
+
   class DOMDocument : public DOMNode {
   public:
     // Build a DOMDocument


More information about the kfm-devel mailing list