No-op eventHandler's passive option

This is a hint to the brower that the listener won't call preventDefault. In
theory, we should enforce this. But in practice, ignoring it should be ok.
This commit is contained in:
Karl Seguin
2025-05-26 21:58:27 +08:00
parent 99b7508c7a
commit f0017c3e92

View File

@@ -48,8 +48,12 @@ pub const EventTarget = struct {
const Opts = struct { const Opts = struct {
capture: ?bool, capture: ?bool,
// We ignore this property. It seems to be largely used to help the
// browser make certain performance tweaks (i.e. the browser knows
// that the listener won't call preventDefault() and thus can safely
// run the default as needed).
passive: ?bool,
once: ?bool, // currently does nothing once: ?bool, // currently does nothing
passive: ?bool, // currently does nothing
signal: ?bool, // currently does nothing signal: ?bool, // currently does nothing
}; };
}; };
@@ -74,7 +78,6 @@ pub const EventTarget = struct {
// better to be explicit and error. // better to be explicit and error.
if (o.once orelse false) return error.NotImplemented; if (o.once orelse false) return error.NotImplemented;
if (o.signal orelse false) return error.NotImplemented; if (o.signal orelse false) return error.NotImplemented;
if (o.passive orelse false) return error.NotImplemented;
capture = o.capture orelse false; capture = o.capture orelse false;
}, },
} }