Skip to content

Commit 0771997

Browse files
committed
Explicit error if an AddEventListenerOption flag is set that we dont' support
1 parent 903168b commit 0771997

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/browser/dom/event_target.zig

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,18 @@ pub const EventTarget = struct {
6565
if (opts_) |opts| {
6666
switch (opts) {
6767
.capture => |c| capture = c,
68-
.opts => |o| capture = o.capture orelse false,
68+
.opts => |o| {
69+
// Done this way so that, for common cases that _only_ set
70+
// capture, i.e. {captrue: true}, it works.
71+
// But for any case that sets any of the other flags, we
72+
// error. If we don't error, this function call would succeed
73+
// but the behavior might be wrong. At this point, it's
74+
// better to be explicit and error.
75+
if (o.once != null) return error.NotImplemented;
76+
if (o.signal != null) return error.NotImplemented;
77+
if (o.passive != null) return error.NotImplemented;
78+
capture = o.capture orelse false;
79+
},
6980
}
7081
}
7182

0 commit comments

Comments
 (0)