mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
[quickjs] getElement works for test case
This commit is contained in:
parent
9d02cfdc46
commit
6d4a573571
@ -26,6 +26,7 @@
|
||||
#include "ecmascript/ecmascript.h"
|
||||
#include "ecmascript/quickjs.h"
|
||||
#include "ecmascript/quickjs/console.h"
|
||||
#include "ecmascript/quickjs/document.h"
|
||||
#include "ecmascript/quickjs/history.h"
|
||||
#include "ecmascript/quickjs/localstorage.h"
|
||||
#include "ecmascript/quickjs/location.h"
|
||||
@ -170,6 +171,7 @@ quickjs_get_interpreter(struct ecmascript_interpreter *interpreter)
|
||||
js_location_init(ctx, global_obj);
|
||||
js_console_init(ctx, global_obj);
|
||||
js_localstorage_init(ctx, global_obj);
|
||||
interpreter->document_obj = js_document_init(ctx, global_obj);
|
||||
|
||||
JS_FreeValue(ctx, global_obj);
|
||||
|
||||
|
@ -1222,7 +1222,6 @@ js_document_getElementById(JSContext *ctx, JSValueConst this_val, int argc, JSVa
|
||||
}
|
||||
xmlpp::ustring id = str;
|
||||
JS_FreeCString(ctx, str);
|
||||
|
||||
xmlpp::ustring xpath = "//*[@id=\"";
|
||||
xpath += id;
|
||||
xpath += "\"]";
|
||||
@ -1598,7 +1597,7 @@ fail:
|
||||
return JS_EXCEPTION;
|
||||
}
|
||||
|
||||
int
|
||||
JSValue
|
||||
js_document_init(JSContext *ctx, JSValue global_obj)
|
||||
{
|
||||
JSValue document_proto, document_class;
|
||||
@ -1616,7 +1615,8 @@ js_document_init(JSContext *ctx, JSValue global_obj)
|
||||
JS_SetClassProto(ctx, js_document_class_id, document_proto);
|
||||
|
||||
JS_SetPropertyStr(ctx, global_obj, "document", document_proto);
|
||||
return 0;
|
||||
|
||||
return document_proto;
|
||||
}
|
||||
|
||||
static const JSCFunctionListEntry js_doctype_proto_funcs[] = {
|
||||
|
@ -4,5 +4,6 @@
|
||||
#include <quickjs/quickjs.h>
|
||||
|
||||
JSValue getDocument(JSContext *ctx, void *doc);
|
||||
JSValue js_document_init(JSContext *ctx, JSValue global_obj);
|
||||
|
||||
#endif
|
||||
|
@ -1647,9 +1647,13 @@ getElement(JSContext *ctx, void *node)
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
||||
#endif
|
||||
JSValue element_obj = JS_NewObject(ctx);
|
||||
/* create the element class */
|
||||
JS_NewClassID(&js_element_class_id);
|
||||
JS_NewClass(JS_GetRuntime(ctx), js_element_class_id, &js_element_class);
|
||||
JSValue element_obj = JS_NewObjectClass(ctx, js_element_class_id);
|
||||
|
||||
JS_SetPropertyFunctionList(ctx, element_obj, js_element_proto_funcs, countof(js_element_proto_funcs));
|
||||
// element_class = JS_NewCFunction2(ctx, js_element_ctor, "element", 0, JS_CFUNC_constructor, 0);
|
||||
// JSValue element_class = JS_NewCFunction2(ctx, js_element_ctor, "element", 0, JS_CFUNC_constructor, 0);
|
||||
// JS_SetConstructor(ctx, element_class, element_obj);
|
||||
JS_SetClassProto(ctx, js_element_class_id, element_obj);
|
||||
JS_SetOpaque(element_obj, node);
|
||||
|
Loading…
Reference in New Issue
Block a user