summaryrefslogtreecommitdiffstats
path: root/WebCore/bindings/v8/custom/V8NodeListCustom.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/bindings/v8/custom/V8NodeListCustom.cpp')
-rw-r--r--WebCore/bindings/v8/custom/V8NodeListCustom.cpp24
1 files changed, 22 insertions, 2 deletions
diff --git a/WebCore/bindings/v8/custom/V8NodeListCustom.cpp b/WebCore/bindings/v8/custom/V8NodeListCustom.cpp
index ad10952..5721a7e 100644
--- a/WebCore/bindings/v8/custom/V8NodeListCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8NodeListCustom.cpp
@@ -29,6 +29,8 @@
*/
#include "config.h"
+#include "V8NodeList.h"
+
#include "NodeList.h"
#include "V8Binding.h"
@@ -40,10 +42,10 @@
namespace WebCore {
-NAMED_PROPERTY_GETTER(NodeList)
+v8::Handle<v8::Value> V8NodeList::namedPropertyGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
{
INC_STATS("DOM.NodeList.NamedPropertyGetter");
- NodeList* list = V8DOMWrapper::convertToNativeObject<NodeList>(V8ClassIndex::NODELIST, info.Holder());
+ NodeList* list = V8NodeList::toNative(info.Holder());
String key = toWebCoreString(name);
// Length property cannot be overridden.
@@ -58,4 +60,22 @@ NAMED_PROPERTY_GETTER(NodeList)
return V8DOMWrapper::convertNodeToV8Object(result.release());
}
+// Need to support call so that list(0) works.
+v8::Handle<v8::Value> V8NodeList::callAsFunctionCallback(const v8::Arguments& args)
+{
+ INC_STATS("DOM.NodeList.callAsFunction()");
+ if (args.Length() < 1)
+ return v8::Undefined();
+
+ NodeList* list = V8NodeList::toNative(args.Holder());
+
+ // The first argument must be a number.
+ v8::Local<v8::Uint32> index = args[0]->ToArrayIndex();
+ if (index.IsEmpty())
+ return v8::Undefined();
+
+ RefPtr<Node> result = list->item(index->Uint32Value());
+ return V8DOMWrapper::convertNodeToV8Object(result.release());
+}
+
} // namespace WebCore