1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-10-27 08:00:32 -04:00

DOM: Definition of attribute callback.

This commit is contained in:
Witold Filipczyk 2007-05-16 21:26:07 +02:00 committed by Witold Filipczyk
parent e53f3b2c99
commit 6da89f7acc
2 changed files with 43 additions and 0 deletions

View File

@ -47,3 +47,43 @@ done_dom_node_ecmascript_obj(struct dom_node *node)
JS_SetPrivate(ctx, obj, NULL);
node->ecmascript_obj = NULL;
}
JSObject *
make_new_object(JSContext *ctx, struct dom_node *node)
{
#if 0
JSObject *obj = create_new_object[node->data.element.type](ctx);
if (obj) {
JS_SetPrivate(ctx, obj, node);
node->ecmascript_obj = obj;
}
return obj;
#endif
return NULL;
}
void
dom_add_attribute(struct dom_node *root, struct dom_node *node, struct dom_string *attr, struct dom_string *value)
{
JSContext *ctx = root->data.document.ecmascript_ctx;
JSObject *obj = node->ecmascript_obj;
JSString *string;
jsval vp;
unsigned char tmp;
if (!obj) {
obj = make_new_object(ctx, node);
if (!obj) return;
}
if (value) {
string = JS_NewString(ctx, value->string, value->length);
vp = STRING_TO_JSVAL(string);
} else {
vp = JSVAL_NULL;
}
tmp = attr->length;
attr->string[attr->length] = '\0';
JS_SetProperty(ctx, obj, attr->string, &vp);
attr->string[attr->length] = tmp;
}

View File

@ -4,6 +4,9 @@
#include "document/dom/ecmascript/spidermonkey/props.h"
struct dom_node;
struct dom_string;
void done_dom_node_ecmascript_obj(struct dom_node *node);
void dom_add_attribute(struct dom_node *root, struct dom_node *parent, struct dom_string *attr, struct dom_string *value);
#endif