Skip to content

Commit 823f4bc

Browse files
TimothyGudomenic
authored andcommitted
Revise event listener removal in document.open()
This change aligns the event listener removal behavior with implementations, specifically in two aspects: - The event handler's value should be set to null (i.e., deactivated). - Event listeners and handlers should be removed from the Window object as well. See prior investigation around deactivation of event handlers in #3836 and #3850. See investigation around document.open()'s behavior in #3818. Tests: web-platform-tests/wpt#12122
1 parent 85e842a commit 823f4bc

File tree

1 file changed

+26
-7
lines changed

1 file changed

+26
-7
lines changed

source

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89889,8 +89889,7 @@ dictionary <dfn>PromiseRejectionEventInit</dfn> : <span>EventInit</span> {
8988989889

8989089890
<p>To <dfn>deactivate an event handler</dfn> given an <code>EventTarget</code> object
8989189891
<var>eventTarget</var> and a string <var>name</var> that is the <span data-x="event handler
89892-
name">name</span> of an <span data-x="event handlers">event handler</span>, take the following
89893-
steps:</p>
89892+
name">name</span> of an <span data-x="event handlers">event handler</span>, run these steps:</p>
8989489893

8989589894
<ol>
8989689895
<li><p>Let <var>handlerMap</var> be <var>eventTarget</var>'s <span>event handler
@@ -89911,10 +89910,24 @@ dictionary <dfn>PromiseRejectionEventInit</dfn> : <span>EventInit</span> {
8991189910
null.</p></li>
8991289911
</ol>
8991389912

89913+
<p>To <dfn>erase all event listeners and handlers</dfn> given an <code>EventTarget</code> object
89914+
<var>eventTarget</var>, run these steps:</p>
89915+
89916+
<ol>
89917+
<li><p>If <var>eventTarget</var> has an associated <span>event handler map</span>, then for each
89918+
<var>name</var> → <var>eventHandler</var> of <var>eventTarget</var>'s associated <span>event
89919+
handler map</span>, <span>deactivate an event handler</span> given <var>eventTarget</var> and
89920+
<var>name</var>.</p></li>
89921+
89922+
<li><p><span>Remove all event listeners</span> given <var>eventTarget</var>.</p></li>
89923+
</ol>
89924+
89925+
<p class="note">This algorithm is used to define <code
89926+
data-x="dom-document-open">document.open(<var>type</var>, <var>replace</var>)</code>.</p>
89927+
8991489928
<p>To <dfn>activate an event handler</dfn> given an <code>EventTarget</code> object
8991589929
<var>eventTarget</var> and a string <var>name</var> that is the <span data-x="event handler
89916-
name">name</span> of an <span data-x="event handlers">event handler</span>, take the following
89917-
steps:</p>
89930+
name">name</span> of an <span data-x="event handlers">event handler</span>, run these steps:</p>
8991889931

8991989932
<ol>
8992089933
<li><p>Let <var>handlerMap</var> be <var>eventTarget</var>'s <span>event handler
@@ -90929,6 +90942,9 @@ document.body.appendChild(frame)</code></pre>
9092990942
<li><p>If <var>document</var> is not an <span>active document</span>, then return
9093090943
<var>document</var>.</p></li>
9093190944

90945+
<li><p>Let <var>window</var> be <var>document</var>'s <span
90946+
data-x="concept-relevant-global">relevant global object</span>.</p></li>
90947+
9093290948
<li><p>If <var>document</var>'s <span>origin</span> is not <span>same origin</span> to the
9093390949
<span>origin</span> of the <span>responsible document</span> specified by the <span>entry
9093490950
settings object</span>, then throw a <span>"<code>SecurityError</code>"</span>
@@ -90983,7 +90999,10 @@ document.body.appendChild(frame)</code></pre>
9098390999
<li><p><span data-x="abort a document">Abort</span> <var>document</var>.</p></li>
9098491000

9098591001
<li><p>For each <span>shadow-including inclusive descendant</span> <var>node</var> of
90986-
<var>document</var>, <span>remove all event listeners</span> with <var>node</var>.</p></li>
91002+
<var>document</var>, <span>erase all event listeners and handlers</span> given
91003+
<var>node</var>.</p></li>
91004+
91005+
<li><p><span>Erase all event listeners and handlers</span> given <var>window</var>.</p></li>
9098791006

9098891007
<li><p>Remove any <span data-x="concept-task">tasks</span> associated with <var>document</var> in
9098991008
any <span>task source</span>.</p></li>
@@ -90998,8 +91017,8 @@ document.body.appendChild(frame)</code></pre>
9099891017
realm</span> with the following customizations:</p>
9099991018

9100091019
<ul>
91001-
<li><p>For the global object, create a new <code>Window</code> object
91002-
<var>window</var>.</p></li>
91020+
<li><p>For the global object, create a new <code>Window</code> object and set
91021+
<var>window</var> to it.</p></li>
9100391022

9100491023
<li><p>For the global <b>this</b> binding, use <var>document</var>'s <span>browsing
9100591024
context</span>'s associated <code>WindowProxy</code>.</p></li>

0 commit comments

Comments
 (0)