mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
[quickjs] event.preventDefault()
This commit is contained in:
parent
3ccb7e664b
commit
da7a525c99
@ -26,6 +26,8 @@ static JSValue js_event_get_property_composed(JSContext *ctx, JSValueConst this_
|
|||||||
static JSValue js_event_get_property_defaultPrevented(JSContext *ctx, JSValueConst this_val);
|
static JSValue js_event_get_property_defaultPrevented(JSContext *ctx, JSValueConst this_val);
|
||||||
static JSValue js_event_get_property_type(JSContext *ctx, JSValueConst this_val);
|
static JSValue js_event_get_property_type(JSContext *ctx, JSValueConst this_val);
|
||||||
|
|
||||||
|
static JSValue js_event_preventDefault(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv);
|
||||||
|
|
||||||
struct eljs_event {
|
struct eljs_event {
|
||||||
char *type_;
|
char *type_;
|
||||||
unsigned int bubbles:1;
|
unsigned int bubbles:1;
|
||||||
@ -57,7 +59,8 @@ static const JSCFunctionListEntry js_event_proto_funcs[] = {
|
|||||||
JS_CGETSET_DEF("cancelable", js_event_get_property_cancelable, NULL),
|
JS_CGETSET_DEF("cancelable", js_event_get_property_cancelable, NULL),
|
||||||
JS_CGETSET_DEF("composed", js_event_get_property_composed, NULL),
|
JS_CGETSET_DEF("composed", js_event_get_property_composed, NULL),
|
||||||
JS_CGETSET_DEF("defaultPrevented", js_event_get_property_defaultPrevented, NULL),
|
JS_CGETSET_DEF("defaultPrevented", js_event_get_property_defaultPrevented, NULL),
|
||||||
JS_CGETSET_DEF("type", js_event_get_property_type, NULL)
|
JS_CGETSET_DEF("type", js_event_get_property_type, NULL),
|
||||||
|
JS_CFUNC_DEF("preventDefault", 0, js_event_preventDefault),
|
||||||
};
|
};
|
||||||
|
|
||||||
static JSValue
|
static JSValue
|
||||||
@ -154,6 +157,25 @@ js_event_get_property_type(JSContext *ctx, JSValueConst this_val)
|
|||||||
RETURN_JS(r);
|
RETURN_JS(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static JSValue
|
||||||
|
js_event_preventDefault(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv)
|
||||||
|
{
|
||||||
|
#ifdef ECMASCRIPT_DEBUG
|
||||||
|
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
||||||
|
#endif
|
||||||
|
REF_JS(this_val);
|
||||||
|
|
||||||
|
struct eljs_event *event = (struct eljs_event *)(JS_GetOpaque(this_val, js_event_class_id));
|
||||||
|
|
||||||
|
if (!event) {
|
||||||
|
return JS_NULL;
|
||||||
|
}
|
||||||
|
if (event->cancelable) {
|
||||||
|
event->defaultPrevented = 1;
|
||||||
|
}
|
||||||
|
return JS_UNDEFINED;
|
||||||
|
}
|
||||||
|
|
||||||
static JSValue
|
static JSValue
|
||||||
js_event_constructor(JSContext *ctx, JSValueConst new_target, int argc, JSValueConst *argv)
|
js_event_constructor(JSContext *ctx, JSValueConst new_target, int argc, JSValueConst *argv)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user