mirror of
https://github.com/rkd77/elinks.git
synced 2024-11-04 08:17:17 -05:00
[ecmascript] element.innerText setter calls element.textContent setter
This commit is contained in:
parent
0b4b09453f
commit
8c40f0dbd4
@ -81,6 +81,7 @@ struct mjs_element_private {
|
||||
|
||||
static void element_event_handler(dom_event *event, void *pw);
|
||||
static void mjs_element_dispatchEvent(js_State *J);
|
||||
static void mjs_element_set_property_textContent(js_State *J);
|
||||
|
||||
void *
|
||||
mjs_getprivate(js_State *J, int idx)
|
||||
@ -1808,27 +1809,7 @@ mjs_element_set_property_innerText(js_State *J)
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
||||
#endif
|
||||
//TODO
|
||||
#if 0
|
||||
const char *val = js_tostring(J, 1);
|
||||
struct ecmascript_interpreter *interpreter = (struct ecmascript_interpreter *)js_getcontext(J);
|
||||
xmlpp::Element *el = static_cast<xmlpp::Element *>(mjs_getprivate(J, 0));
|
||||
|
||||
if (!el) {
|
||||
js_pushundefined(J);
|
||||
return;
|
||||
}
|
||||
auto children = el->get_children();
|
||||
auto it = children.begin();
|
||||
auto end = children.end();
|
||||
|
||||
for (;it != end; ++it) {
|
||||
xmlpp::Node::remove_node(*it);
|
||||
}
|
||||
el->add_child_text(val);
|
||||
interpreter->changed = 1;
|
||||
#endif
|
||||
js_pushundefined(J);
|
||||
mjs_element_set_property_textContent(J);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -64,6 +64,7 @@ struct js_element_private {
|
||||
};
|
||||
|
||||
static void element_event_handler(dom_event *event, void *pw);
|
||||
static JSValue js_element_set_property_textContent(JSContext *ctx, JSValueConst this_val, JSValue val);
|
||||
|
||||
void *
|
||||
js_getopaque(JSValueConst obj, JSClassID class_id)
|
||||
@ -1944,36 +1945,7 @@ js_element_set_property_innerText(JSContext *ctx, JSValueConst this_val, JSValue
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
||||
#endif
|
||||
REF_JS(this_val);
|
||||
REF_JS(val);
|
||||
|
||||
// TODO
|
||||
#if 0
|
||||
struct ecmascript_interpreter *interpreter = (struct ecmascript_interpreter *)JS_GetContextOpaque(ctx);
|
||||
xmlpp::Element *el = static_cast<xmlpp::Element *>(js_getopaque(this_val, js_element_class_id));
|
||||
|
||||
if (!el) {
|
||||
return JS_UNDEFINED;
|
||||
}
|
||||
auto children = el->get_children();
|
||||
auto it = children.begin();
|
||||
auto end = children.end();
|
||||
|
||||
for (;it != end; ++it) {
|
||||
xmlpp::Node::remove_node(*it);
|
||||
}
|
||||
size_t len;
|
||||
const char *str = JS_ToCStringLen(ctx, &len, val);
|
||||
|
||||
if (!str) {
|
||||
return JS_EXCEPTION;
|
||||
}
|
||||
el->add_child_text(str);
|
||||
interpreter->changed = 1;
|
||||
JS_FreeCString(ctx, str);
|
||||
#endif
|
||||
|
||||
return JS_UNDEFINED;
|
||||
return js_element_set_property_textContent(ctx, this_val, val);
|
||||
}
|
||||
|
||||
static JSValue
|
||||
|
@ -3260,64 +3260,13 @@ out:
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
element_set_property_innerText(JSContext *ctx, unsigned int argc, JS::Value *vp)
|
||||
{
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
||||
#endif
|
||||
JS::CallArgs args = CallArgsFromVp(argc, vp);
|
||||
JS::RootedObject hobj(ctx, &args.thisv().toObject());
|
||||
|
||||
JS::Realm *comp = js::GetContextRealm(ctx);
|
||||
|
||||
if (!comp) {
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "%s:%s %d\n", __FILE__, __FUNCTION__, __LINE__);
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
/* This can be called if @obj if not itself an instance of the
|
||||
* appropriate class but has one in its prototype chain. Fail
|
||||
* such calls. */
|
||||
if (!JS_InstanceOf(ctx, hobj, &element_class, NULL)) {
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "%s:%s %d\n", __FILE__, __FUNCTION__, __LINE__);
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
// TODO
|
||||
struct view_state *vs = interpreter->vs;
|
||||
if (!vs) {
|
||||
return true;
|
||||
}
|
||||
struct document_view *doc_view = vs->doc_view;
|
||||
struct document *document = doc_view->document;
|
||||
|
||||
dom_node *el = JS::GetMaybePtrFromReservedSlot<dom_node>(hobj, 0);
|
||||
if (!el) {
|
||||
return true;
|
||||
}
|
||||
|
||||
auto children = el->get_children();
|
||||
auto it = children.begin();
|
||||
auto end = children.end();
|
||||
for (;it != end; ++it) {
|
||||
xmlpp::Node::remove_node(*it);
|
||||
}
|
||||
|
||||
char *text = jsval_to_string(ctx, args[0]);
|
||||
el->add_child_text(text);
|
||||
interpreter->changed = 1;
|
||||
mem_free_if(text);
|
||||
debug_dump_xhtml(document->dom);
|
||||
#endif
|
||||
|
||||
return true;
|
||||
return element_set_property_textContent(ctx, argc, vp);
|
||||
}
|
||||
|
||||
static bool
|
||||
|
Loading…
Reference in New Issue
Block a user