Skip to content

Commit fb1e711

Browse files
Avoid executing the code in the All Fetch Listeners Are Empty algorithm. (#1676)
* Avoid executing the code in the All Fetch Listeners Are Empty algorithm. * Removed redundant check. * Add a note that clarify that we ignores handleEvent. * Updated the note as suggested.
1 parent 4b38437 commit fb1e711

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

docs/index.bs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3009,11 +3009,11 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/
30093009
1. Let |callback| be null.
30103010
1. If |eventHandler| is not null and |eventListenerCallback| equals |eventHandler|'s [=event handler/listener=]'s [=event listener/callback=], then set |callback| to the result of [=convert to an ECMAScript value|converting to an ECMAScript value=] |eventHandler|'s [=event handler/value=].
30113011
1. Otherwise, set |callback| to the result of [=convert to an ECMAScript value|converting to an ECMAScript value=] |eventListenerCallback|.
3012-
1. If [$IsCallable$](|callback|) is false:
3013-
1. Let |getResult| be [=Completion=]([$Get$](|callback|), <code>handleEvent</code>).
3014-
1. If |getResult| is [=abrupt completion=], then return false.
3015-
1. Set |callback| to |getResult|.
3016-
1. If [$IsCallable$](|callback|) is false, or |callback|'s [=function body=] is not empty (i.e. either a [=statement=] or [=declaration=] exist), then return false.
3012+
1. If [$IsCallable$](|callback|) is false, then return false.
3013+
3014+
Note: [=Event listener/Callback=] objects that use {{handleEvent}} are assumed to be non-empty. This avoids calling the {{handleEvent}} getters, which could modify the event listeners during this check.
3015+
3016+
1. If |callback|'s [=function body=] is not empty (i.e. either a [=statement=] or [=declaration=] exist), then return false.
30173017

30183018
Note: This detects "<code>fetch</code>" listeners like `() => {}`. Some sites have a fetch event listener with empty body to make them recognized by Chromium as a progressive web application (PWA).
30193019

0 commit comments

Comments
 (0)