New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EventTarget#addEventListener mishandles nullish "signal" option #14254
Comments
|
The code there is quite outdated, and should be using webidl converters. There are many examples of such across the codebase, including the same file: Lines 114 to 126 in 8ae1702
which is then used later: Lines 158 to 161 in 8ae1702
|
|
From the spec, it states that the signal property can be null.
|
@randomicon00 I think null is not the javascript there is a wpt test which states a |
If anything, the code snippet that I provide yields different results than Deno when evaluated in a browser (do try it yourself). |
|
@Garcia101 what's your deno version? "AddEventListenerOptions.signal shouldn't be nullable" fix is landed at version v1.12.0, so if you using version lower than version 1.12.0, then the problem will exist. fix pr: #11348 I am using version 1.20.6, the problem is not exist $ cat test.js
const et = new EventTarget();
et.addEventListener("foo", () => {}, { signal: null });
$ deno run test.js
error: Uncaught TypeError: signal must be non-null
et.addEventListener("foo", () => {}, { signal: null });
^
at EventTarget.addEventListener (deno:ext/web/02_event.js:939:15)
at file:///Users/feng/dev/deno/test.js:2:4Deno Version$ deno --version
deno 1.20.6 (release, x86_64-apple-darwin)
v8 10.0.139.6
typescript 4.6.2 |
I just ran this, to be fully certain: const event_target = new EventTarget();
event_target.addEventListener("abc", null, {
signal: null
});
console.log(Deno.version);output: I also tried on the non-canary release, Furthermore, note that I reference what happens to be the code intended to prevent this bug, in the issue message itself:
That very code coincidentally comes from the PR that was intended to fix this issue. The current implementation is erroneous and misaligned with the appropriate specification, as WebIDL type conversions are up-front, whereas this code is evaluated conditionally, that is, if the handler callback function is not |
|
@Garcia101 my bad. I copy the snippet from the wpt test. I can reproduce this problem when I execute your snippet. |
Currently, Deno accepts this example snippet without error:
According to https://dom.spec.whatwg.org/#eventtarget, EventTarget#addEventListener is defined as
Note the
AbortSignal signal, which doesn't allow thesignalvalue to be null, if the object property is present.From a quick skim, it seems to be that this branch isn't being reached, even though it's intended to be?
deno/ext/web/02_event.js
Lines 932 to 934 in 8ae1702
The text was updated successfully, but these errors were encountered: