mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-08-01 02:06:17 -04:00
webapi: invoke MutationObserver callbacks with the observer as this
Fixes WPT /dom/nodes/MutationObserver-callback-arguments.html: per the
DOM spec ("invoke callback with a list of MutationRecord objects and mo,
and mo as callback this value"), the mutation callback's this value must
be the MutationObserver itself. We invoked it with the default receiver
(undefined -> globalThis), so `this === mo` failed.
deliverRecords now uses tryCallWithThis with the observer as receiver.
Coverage: /dom/nodes/MutationObserver-callback-arguments.html 0/1 -> 1/1
(fully green).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
committed by
Karl Seguin
parent
a603721f5f
commit
575ca0000c
@@ -350,7 +350,8 @@ pub fn deliverRecords(self: *MutationObserver, frame: *Frame) !void {
|
||||
defer ls.deinit();
|
||||
|
||||
var caught: js.TryCatch.Caught = undefined;
|
||||
ls.toLocal(self._callback).tryCall(void, .{ records, self }, &caught) catch |err| {
|
||||
// Per spec, the callback is invoked with the observer as its this value.
|
||||
ls.toLocal(self._callback).tryCallWithThis(void, self, .{ records, self }, &caught) catch |err| {
|
||||
log.err(.frame, "MutObserver.deliverRecords", .{ .err = err, .caught = caught });
|
||||
return err;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user