patch to add item method for DOM nodes (JavaScript)
Darin Adler
darin at apple.com
Tue Oct 28 21:42:27 CET 2003
Someone gave me a piece of JavaScript from techcu.com that worked in
both IE and Mozilla, but not Safari. I narrowed it down to the fact
that those other browsers have an item method right on the DOM nodes. I
even found some documentation about it in the Gecko DOM reference, and
I'm sure I could find something on the Microsoft site too, but I didn't
look.
Maybe there are some other methods like this that we're also missing.
But here's this one for now.
-------------- next part --------------
Index: ChangeLog
===================================================================
RCS file: /local/home/cvs/Labyrinth/WebCore/ChangeLog,v
retrieving revision 1.2141
diff -p -u -u -p -r1.2141 ChangeLog
--- ChangeLog 2003/10/29 01:23:15 1.2141
+++ ChangeLog 2003/10/29 05:40:24
@@ -1,3 +1,13 @@
+2003-10-28 Darin Adler <darin at apple.com>
+
+ Reviewed by Maciej.
+
+ - fixed 3464702 -- node.item(x) is not implemented (dynamic menus not filled out at techcu.com)
+
+ * khtml/ecma/kjs_dom.cpp: (DOMNodeProtoFunc::tryCall): Add implementation of item function.
+ * khtml/ecma/kjs_dom.h: Added Item to the enum.
+ * khtml/ecma/kjs_dom.lut.h: Regenerated.
+
2003-10-28 Maciej Stachowiak <mjs at apple.com>
Reviewed by Dave,
@@ -29,7 +39,7 @@
Index: khtml/ecma/kjs_dom.cpp
===================================================================
RCS file: /local/home/cvs/Labyrinth/WebCore/khtml/ecma/kjs_dom.cpp,v
retrieving revision 1.35
diff -p -u -u -p -r1.35 khtml/ecma/kjs_dom.cpp
--- khtml/ecma/kjs_dom.cpp 2003/10/07 20:15:59 1.35
+++ khtml/ecma/kjs_dom.cpp 2003/10/29 05:40:25
@@ -61,6 +61,8 @@ using DOM::DOMException;
removeEventListener DOMNode::RemoveEventListener DontDelete|Function 3
dispatchEvent DOMNode::DispatchEvent DontDelete|Function 1
contains DOMNode::Contains DontDelete|Function 1
+# "DOM level 0" (from Gecko DOM reference; also in WinIE)
+ item DOMNode::Item DontDelete|Function 1
@end
*/
DEFINE_PROTOTYPE("DOMNode",DOMNodeProto)
@@ -475,7 +477,10 @@ Value DOMNodeProtoFunc::tryCall(ExecStat
bool retval = !impl->checkNoOwner(other.handle(),exceptioncode);
return Boolean(retval && exceptioncode == 0);
}
+ return Undefined();
}
+ case DOMNode::Item:
+ return getDOMNode(exec, node.childNodes().item(static_cast<unsigned long>(args[0].toNumber(exec))));
}
return Undefined();
Index: khtml/ecma/kjs_dom.h
===================================================================
RCS file: /local/home/cvs/Labyrinth/WebCore/khtml/ecma/kjs_dom.h,v
retrieving revision 1.18
diff -p -u -u -p -r1.18 khtml/ecma/kjs_dom.h
--- khtml/ecma/kjs_dom.h 2003/08/18 21:12:40 1.18
+++ khtml/ecma/kjs_dom.h 2003/10/29 05:40:25
@@ -54,7 +54,7 @@ namespace KJS {
virtual void pushEventHandlerScope(ExecState *exec, ScopeChain &scope) const;
enum { NodeName, NodeValue, NodeType, ParentNode, ParentElement,
- ChildNodes, FirstChild, LastChild, PreviousSibling, NextSibling,
+ ChildNodes, FirstChild, LastChild, PreviousSibling, NextSibling, Item,
Attributes, NamespaceURI, Prefix, LocalName, OwnerDocument, InsertBefore,
ReplaceChild, RemoveChild, AppendChild, HasAttributes, HasChildNodes,
CloneNode, Normalize, IsSupported, AddEventListener, RemoveEventListener,
-------------- next part --------------
-- Darin
More information about the Khtml-devel
mailing list