summaryrefslogtreecommitdiff
path: root/javascript/jsapi/nodelist.bnd
diff options
context:
space:
mode:
authorOle Loots <ole@monochrom.net>2013-01-31 19:28:26 +0100
committerOle Loots <ole@monochrom.net>2013-01-31 19:28:26 +0100
commit0703404654d2a40cacae2d94c6e0e22ca28b4acf (patch)
treebfdbe1e8952814f73a6b0e190ae0a77fd0cfc7bd /javascript/jsapi/nodelist.bnd
parent54f719aa960159c5b1978846223732c9669ca7fa (diff)
parent89856f55929907642013e45435b9d18cd1fafe36 (diff)
downloadnetsurf-0703404654d2a40cacae2d94c6e0e22ca28b4acf.tar.gz
netsurf-0703404654d2a40cacae2d94c6e0e22ca28b4acf.tar.bz2
Merge branch 'master' into mono/removing-windom-dependencymono/removing-windom-dependency
Conflicts: atari/toolbar.c
Diffstat (limited to 'javascript/jsapi/nodelist.bnd')
-rw-r--r--javascript/jsapi/nodelist.bnd41
1 files changed, 35 insertions, 6 deletions
diff --git a/javascript/jsapi/nodelist.bnd b/javascript/jsapi/nodelist.bnd
index 4aa8c47f5..379809659 100644
--- a/javascript/jsapi/nodelist.bnd
+++ b/javascript/jsapi/nodelist.bnd
@@ -39,6 +39,41 @@ binding nodelist {
private "struct html_content *" htmlc;
}
+api finalise %{
+ if (private != NULL) {
+ dom_nodelist_unref(private->nodelist);
+ }
+%}
+
+/* default handler for numericaly indexed property values */
+api getproperty %{
+ jsval queryprop;
+ int idx;
+ JSObject *jsret = NULL; /* Node */
+ dom_exception err;
+ dom_node *domnode;
+
+ JSAPI_PROP_IDVAL(cx, &queryprop);
+ if (JSVAL_IS_INT(queryprop)) {
+ idx = JSVAL_TO_INT(queryprop);
+ JSDBG("Index was %d", idx);
+
+
+ err = dom_nodelist_item(private->nodelist, idx, &domnode);
+ if (err != DOM_NO_ERR) {
+ return JS_FALSE;
+ }
+
+ if (domnode != NULL) {
+ jsret = jsapi_new_HTMLElement(cx, NULL, NULL, (dom_element *)domnode, private->htmlc);
+
+ JSDBG("return object:%p", jsret);
+
+ JSAPI_PROP_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(jsret));
+ }
+ }
+%}
+
getter length %{
dom_exception err;
@@ -62,9 +97,3 @@ operation item %{
}
%}
-api finalise %{
- if (private != NULL) {
- dom_nodelist_unref(private->nodelist);
- }
-%}
-