1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-10-11 05:29:28 -04:00

DOM HTMLOptionsCollection: Reused HTMLCollection.

Note that the length property is read-only now.
This commit is contained in:
Witold Filipczyk 2007-06-12 16:49:06 +02:00 committed by Witold Filipczyk
parent 46584fc5c0
commit 6e010d76ff
3 changed files with 29 additions and 28 deletions

View File

@ -9,7 +9,7 @@
#include "document/dom/ecmascript/spidermonkey/html/HTMLElement.h"
#include "dom/node.h"
static JSBool
JSBool
HTMLCollection_item(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv,
jsval *rval)
{
@ -36,7 +36,7 @@ HTMLCollection_item(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv,
return JS_TRUE;
}
static JSBool
JSBool
HTMLCollection_namedItem(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv,
jsval *rval)
{

View File

@ -7,4 +7,7 @@ extern const JSClass HTMLCollection_class;
extern const JSFunctionSpec HTMLCollection_funcs[];
extern const JSPropertySpec HTMLCollection_props[];
JSBool HTMLCollection_item(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
JSBool HTMLCollection_namedItem(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
#endif

View File

@ -6,48 +6,46 @@
#include "document/dom/ecmascript/spidermonkey.h"
#include "document/dom/ecmascript/spidermonkey/Node.h"
#include "document/dom/ecmascript/spidermonkey/html/HTMLCollection.h"
#include "document/dom/ecmascript/spidermonkey/html/HTMLOptionsCollection.h"
#include "dom/node.h"
static JSBool
HTMLOptionsCollection_getProperty(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
{
if (!JSVAL_IS_INT(id))
return JS_TRUE;
struct dom_node_list *list;
switch (JSVAL_TO_INT(id)) {
case JSP_HTML_OPTIONS_COLLECTION_LENGTH:
/* Write me! */
break;
default:
break;
if (!obj || (!JS_InstanceOf(ctx, obj, (JSClass *)&HTMLOptionsCollection_class, NULL)))
return JS_FALSE;
list = JS_GetPrivate(ctx, obj);
if (!list)
return JS_FALSE;
if (JSVAL_IS_STRING(id))
return HTMLCollection_namedItem(ctx, obj, 1, &id, vp);
if (JSVAL_IS_INT(id)) {
switch (JSVAL_TO_INT(id)) {
case JSP_HTML_OPTIONS_COLLECTION_LENGTH:
int_to_jsval(ctx, vp, list->size);
break;
default:
return HTMLCollection_item(ctx, obj, 1, &id, vp);
break;
}
}
return JS_TRUE;
}
static JSBool
HTMLOptionsCollection_item(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv,
jsval *rval)
{
/* Write me! */
return JS_TRUE;
}
static JSBool
HTMLOptionsCollection_namedItem(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv,
jsval *rval)
{
/* Write me! */
return JS_TRUE;
}
const JSPropertySpec HTMLOptionsCollection_props[] = {
{ "length", JSP_HTML_OPTIONS_COLLECTION_LENGTH, JSPROP_ENUMERATE | JSPROP_READONLY },
{ NULL }
};
const JSFunctionSpec HTMLOptionsCollection_funcs[] = {
{ "item", HTMLOptionsCollection_item, 1 },
{ "namedItem", HTMLOptionsCollection_namedItem, 1 },
{ "item", HTMLCollection_item, 1 },
{ "namedItem", HTMLCollection_namedItem, 1 },
{ NULL }
};