Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit03fb789

Browse files
authored
events: add null check for the signal of EventTarget
This will improve the Web compatibility.Passing null as the signal should throw an error.WPT says "Passing null as the signal should throw".Please seehttps://github.com/web-platform-tests/wpt/blob/master/dom/events/AddEventListenerOptions-signal.any.jsPR-URL:#43153Reviewed-By: Luigi Pinca <luigipinca@gmail.com>Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>Reviewed-By: Tobias Nießen <tniessen@tnie.de>Reviewed-By: Colin Ihrig <cjihrig@gmail.com>Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent4884746 commit03fb789

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

‎lib/internal/event_target.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const {
3434
ERR_INVALID_THIS,
3535
}
3636
}=require('internal/errors');
37-
const{ validateObject, validateString, validateInternalField}=require('internal/validators');
37+
const{validateAbortSignal,validateObject, validateString, validateInternalField}=require('internal/validators');
3838

3939
const{
4040
customInspectSymbol,
@@ -575,6 +575,8 @@ class EventTarget {
575575
}
576576
type=String(type);
577577

578+
validateAbortSignal(signal,'options.signal');
579+
578580
if(signal){
579581
if(signal.aborted){
580582
return;

‎test/parallel/test-whatwg-events-add-event-listener-options-signal.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ require('../common');
44

55
const{
66
strictEqual,
7+
throws,
78
}=require('assert');
89

910
// Manually ported from: wpt@dom/events/AddEventListenerOptions-signal.any.js
@@ -157,3 +158,11 @@ const {
157158
},{once:true});
158159
et.dispatchEvent(newEvent('foo'));
159160
}
161+
{
162+
constet=newEventTarget();
163+
[1,1n,{},[],null,true,'hi',Symbol(),()=>{}].forEach((signal)=>{
164+
throws(()=>et.addEventListener('foo',()=>{},{ signal}),{
165+
name:'TypeError',
166+
});
167+
});
168+
}

‎test/wpt/status/dom/events.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
"AddEventListenerOptions-signal.any.js": {
1212
"fail": {
1313
"expected": [
14-
"Passing null as the signal should throw",
1514
"Passing null as the signal should throw (listener is also null)"
1615
]
1716
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp