mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 03:27:45 +00:00
LibWeb: Return undefined from event handler setters, not an empty value
This commit is contained in:
parent
a1a164e6b8
commit
1a7136b37a
1 changed files with 31 additions and 29 deletions
|
@ -682,35 +682,37 @@ JS_DEFINE_NATIVE_FUNCTION(WindowObject::history_getter)
|
||||||
return wrap(global_object, impl->associated_document().history());
|
return wrap(global_object, impl->associated_document().history());
|
||||||
}
|
}
|
||||||
|
|
||||||
#define __ENUMERATE(attribute, event_name) \
|
#define __ENUMERATE(attribute, event_name) \
|
||||||
JS_DEFINE_NATIVE_FUNCTION(WindowObject::attribute##_getter) \
|
JS_DEFINE_NATIVE_FUNCTION(WindowObject::attribute##_getter) \
|
||||||
{ \
|
{ \
|
||||||
auto* impl = impl_from(vm, global_object); \
|
auto* impl = impl_from(vm, global_object); \
|
||||||
if (!impl) \
|
if (!impl) \
|
||||||
return {}; \
|
return {}; \
|
||||||
auto retval = impl->attribute(); \
|
auto retval = impl->attribute(); \
|
||||||
if (retval.callback.is_null()) \
|
if (retval.callback.is_null()) \
|
||||||
return JS::js_null(); \
|
return JS::js_null(); \
|
||||||
return retval.callback.cell(); \
|
return retval.callback.cell(); \
|
||||||
} \
|
} \
|
||||||
JS_DEFINE_NATIVE_FUNCTION(WindowObject::attribute##_setter) \
|
JS_DEFINE_NATIVE_FUNCTION(WindowObject::attribute##_setter) \
|
||||||
{ \
|
{ \
|
||||||
auto* impl = impl_from(vm, global_object); \
|
auto* impl = impl_from(vm, global_object); \
|
||||||
if (!impl) \
|
if (!impl) \
|
||||||
return {}; \
|
return {}; \
|
||||||
auto value = vm.argument(0); \
|
auto value = vm.argument(0); \
|
||||||
HTML::EventHandler cpp_value; \
|
HTML::EventHandler cpp_value; \
|
||||||
if (value.is_function()) { \
|
if (value.is_function()) { \
|
||||||
cpp_value.callback = JS::make_handle(&value.as_function()); \
|
cpp_value.callback = JS::make_handle(&value.as_function()); \
|
||||||
} else if (value.is_string()) { \
|
} else if (value.is_string()) { \
|
||||||
cpp_value.string = value.as_string().string(); \
|
cpp_value.string = value.as_string().string(); \
|
||||||
} else { \
|
} else { \
|
||||||
return {}; \
|
return JS::js_undefined(); \
|
||||||
} \
|
} \
|
||||||
(void)throw_dom_exception_if_needed(vm, global_object, [&] { \
|
auto result = throw_dom_exception_if_needed(vm, global_object, [&] { \
|
||||||
return impl->set_##attribute(cpp_value); \
|
return impl->set_##attribute(cpp_value); \
|
||||||
}); \
|
}); \
|
||||||
return {}; \
|
if (should_return_empty(result)) \
|
||||||
|
return {}; \
|
||||||
|
return JS::js_undefined(); \
|
||||||
}
|
}
|
||||||
ENUMERATE_GLOBAL_EVENT_HANDLERS(__ENUMERATE)
|
ENUMERATE_GLOBAL_EVENT_HANDLERS(__ENUMERATE)
|
||||||
#undef __ENUMERATE
|
#undef __ENUMERATE
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue