LibWeb: Use ResizeObserver instance as this in callback function

This commit is contained in:
Aliaksandr Kalenik 2025-09-07 16:59:08 +02:00 committed by Alexander Kalenik
commit 1cc9fb6135
Notes: github-actions[bot] 2025-09-08 16:41:23 +00:00
2 changed files with 6 additions and 2 deletions

View file

@ -116,7 +116,7 @@ void ResizeObserver::invoke_callback(ReadonlySpan<GC::Ref<ResizeObserverEntry>>
MUST(wrapped_records->create_data_property(property_index, record.ptr()));
}
(void)WebIDL::invoke_callback(callback, JS::js_undefined(), WebIDL::ExceptionBehavior::Report, { { wrapped_records } });
(void)WebIDL::invoke_callback(callback, this, WebIDL::ExceptionBehavior::Report, { { wrapped_records } });
}
void ResizeObserver::unregister_observer_if_needed()

View file

@ -23,7 +23,11 @@
});
}
const resizeObserver = new ResizeObserver(entries => {
const resizeObserver = new ResizeObserver(function (entries) {
if (this !== resizeObserver) {
println("this is not the ResizeObserver instance inside callback");
}
for (let entry of entries) {
const { width, height } = entry.contentRect;
println(`Size changed: ${width}px x ${height}px`);