From f0017c3e9263dc3d57828eecbfee9ad6542ff7ad Mon Sep 17 00:00:00 2001 From: Karl Seguin Date: Mon, 26 May 2025 21:58:27 +0800 Subject: [PATCH] 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. --- src/browser/dom/event_target.zig | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/browser/dom/event_target.zig b/src/browser/dom/event_target.zig index fb21d424..e34e3690 100644 --- a/src/browser/dom/event_target.zig +++ b/src/browser/dom/event_target.zig @@ -48,8 +48,12 @@ pub const EventTarget = struct { const Opts = struct { 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 - passive: ?bool, // currently does nothing signal: ?bool, // currently does nothing }; }; @@ -74,7 +78,6 @@ pub const EventTarget = struct { // better to be explicit and error. if (o.once 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; }, }