Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[giow] (3) Bring onbeforeunload handling closer to compatibility with…
… the Web

Fixing https://www.w3.org/Bugs/Public/show_bug.cgi?id=19713
Affected topics: HTML

git-svn-id: http://svn.whatwg.org/webapps@7933 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information
Hixie committed Jun 7, 2013
1 parent 8ca4eee commit 7612afe
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 21 deletions.
30 changes: 24 additions & 6 deletions complete.html
Expand Up @@ -256,7 +256,7 @@

<header class=head id=head><p><a class=logo href=http://www.whatwg.org/><img alt=WHATWG height=101 src=/images/logo width=101></a></p>
<hgroup><h1 class=allcaps>HTML</h1>
<h2 class="no-num no-toc">Living Standard &mdash; Last Updated 6 June 2013</h2>
<h2 class="no-num no-toc">Living Standard &mdash; Last Updated 7 June 2013</h2>
</hgroup><dl><dt><strong>Web developer edition:</strong></dt>
<dd><strong><a href=http://developers.whatwg.org/>http://developers.whatwg.org/</a></strong></dd>
<dt>Multiple-page version:</dt>
Expand Down Expand Up @@ -71769,11 +71769,22 @@ <h5 id=event-handler-attributes><span class=secno>7.1.6.1 </span>Event handlers<

<dd><p>If <var title="">return value</var> is a WebIDL boolean true value, then cancel the event.</dd>

<dt>If the <code><a href=#event>Event</a></code> object <var title="">E</var> is a <code><a href=#beforeunloadevent>BeforeUnloadEvent</a></code>
object</dt>

<dd><p>If <var title="">return value</var> is a WebIDL string value, and the <code><a href=#event>Event</a></code> object <var title="">E</var>'s <code title=dom-BeforeUnloadEvent-returnValue><a href=#dom-beforeunloadevent-returnvalue>returnValue</a></code>
attribute's value is the empty string, then set the <code title=dom-BeforeUnloadEvent-returnValue><a href=#dom-beforeunloadevent-returnvalue>returnValue</a></code> attribute's value to <var title="">return value</var>.</dd>
<dt>If the event type is <code class=event-beforeunload>beforeunload</code></dt>

<dd>

<p class=note>The <span>event handler IDL attribute</span>'s type is
<code><a href=#onbeforeunloadeventhandler>OnBeforeUnloadEventHandler</a></code>, and the <var title="">return value</var> will
therefore have been coerced into either the value null or a DOMString.</p>

<p>If the <var title="">return value</var> is null, then cancel the event.</p>

<p>Otherwise, If the <code><a href=#event>Event</a></code> object <var title="">E</var> is a
<code><a href=#beforeunloadevent>BeforeUnloadEvent</a></code> object, and the <code><a href=#event>Event</a></code> object <var title="">E</var>'s <code title=dom-BeforeUnloadEvent-returnValue><a href=#dom-beforeunloadevent-returnvalue>returnValue</a></code>
attribute's value is the empty string, then set the <code title=dom-BeforeUnloadEvent-returnValue><a href=#dom-beforeunloadevent-returnvalue>returnValue</a></code> attribute's value to <var title="">return value</var>.</p>

</dd>

<dt>Otherwise</dt>

Expand Down Expand Up @@ -71819,6 +71830,13 @@ <h5 id=event-handler-attributes><span class=secno>7.1.6.1 </span>Event handlers<
callback <dfn id=onerroreventhandlernonnull>OnErrorEventHandlerNonNull</dfn> = any ((<a href=#event>Event</a> or DOMString) event, optional DOMString source, optional unsigned long lineno, optional unsigned long column);
typedef <a href=#onerroreventhandlernonnull>OnErrorEventHandlerNonNull</a>? <dfn id=onerroreventhandler>OnErrorEventHandler</dfn>;</pre>

<p>Similarly, the <code title=handler-window-onbeforeunload><a href=#handler-window-onbeforeunload>onbeforeunload</a></code> handler has a
different return value:</p>

<pre class=idl>[TreatNonCallableAsNull]
callback <dfn id=onbeforeunloadeventhandlernonnull>OnBeforeUnloadEventHandlerNonNull</dfn> = DOMString (<a href=#event>Event</a> event);
typedef <a href=#onbeforeunloadeventhandlernonnull>OnBeforeUnloadEventHandlerNonNull</a>? <dfn id=onbeforeunloadeventhandler>OnBeforeUnloadEventHandler</dfn>;</pre>

<!-- onreadystatechange is also defined specially, using [LenientThis]; see IDL -->


Expand Down Expand Up @@ -72017,7 +72035,7 @@ <h5 id=event-handlers-on-elements,-document-objects,-and-window-objects><span cl
interface <dfn id=windoweventhandlers>WindowEventHandlers</dfn> {
attribute <a href=#eventhandler>EventHandler</a> <a href=#handler-window-onafterprint title=handler-window-onafterprint>onafterprint</a>;
attribute <a href=#eventhandler>EventHandler</a> <a href=#handler-window-onbeforeprint title=handler-window-onbeforeprint>onbeforeprint</a>;
attribute <a href=#eventhandler>EventHandler</a> <a href=#handler-window-onbeforeunload title=handler-window-onbeforeunload>onbeforeunload</a>;
attribute <a href=#onbeforeunloadeventhandler>OnBeforeUnloadEventHandler</a> <a href=#handler-window-onbeforeunload title=handler-window-onbeforeunload>onbeforeunload</a>;
attribute <a href=#eventhandler>EventHandler</a> <a href=#handler-window-onhashchange title=handler-window-onhashchange>onhashchange</a>;
attribute <a href=#eventhandler>EventHandler</a> <a href=#handler-window-onmessage title=handler-window-onmessage>onmessage</a>;
attribute <a href=#eventhandler>EventHandler</a> <a href=#handler-window-onoffline title=handler-window-onoffline>onoffline</a>;
Expand Down
30 changes: 24 additions & 6 deletions index
Expand Up @@ -256,7 +256,7 @@

<header class=head id=head><p><a class=logo href=http://www.whatwg.org/><img alt=WHATWG height=101 src=/images/logo width=101></a></p>
<hgroup><h1 class=allcaps>HTML</h1>
<h2 class="no-num no-toc">Living Standard &mdash; Last Updated 6 June 2013</h2>
<h2 class="no-num no-toc">Living Standard &mdash; Last Updated 7 June 2013</h2>
</hgroup><dl><dt><strong>Web developer edition:</strong></dt>
<dd><strong><a href=http://developers.whatwg.org/>http://developers.whatwg.org/</a></strong></dd>
<dt>Multiple-page version:</dt>
Expand Down Expand Up @@ -71769,11 +71769,22 @@ currently this is unnecessary: http://www.w3.org/Bugs/Public/show_bug.cgi?id=119

<dd><p>If <var title="">return value</var> is a WebIDL boolean true value, then cancel the event.</dd>

<dt>If the <code><a href=#event>Event</a></code> object <var title="">E</var> is a <code><a href=#beforeunloadevent>BeforeUnloadEvent</a></code>
object</dt>

<dd><p>If <var title="">return value</var> is a WebIDL string value, and the <code><a href=#event>Event</a></code> object <var title="">E</var>'s <code title=dom-BeforeUnloadEvent-returnValue><a href=#dom-beforeunloadevent-returnvalue>returnValue</a></code>
attribute's value is the empty string, then set the <code title=dom-BeforeUnloadEvent-returnValue><a href=#dom-beforeunloadevent-returnvalue>returnValue</a></code> attribute's value to <var title="">return value</var>.</dd>
<dt>If the event type is <code class=event-beforeunload>beforeunload</code></dt>

<dd>

<p class=note>The <span>event handler IDL attribute</span>'s type is
<code><a href=#onbeforeunloadeventhandler>OnBeforeUnloadEventHandler</a></code>, and the <var title="">return value</var> will
therefore have been coerced into either the value null or a DOMString.</p>

<p>If the <var title="">return value</var> is null, then cancel the event.</p>

<p>Otherwise, If the <code><a href=#event>Event</a></code> object <var title="">E</var> is a
<code><a href=#beforeunloadevent>BeforeUnloadEvent</a></code> object, and the <code><a href=#event>Event</a></code> object <var title="">E</var>'s <code title=dom-BeforeUnloadEvent-returnValue><a href=#dom-beforeunloadevent-returnvalue>returnValue</a></code>
attribute's value is the empty string, then set the <code title=dom-BeforeUnloadEvent-returnValue><a href=#dom-beforeunloadevent-returnvalue>returnValue</a></code> attribute's value to <var title="">return value</var>.</p>

</dd>

<dt>Otherwise</dt>

Expand Down Expand Up @@ -71819,6 +71830,13 @@ typedef <a href=#eventhandlernonnull>EventHandlerNonNull</a>? <dfn id=eventhandl
callback <dfn id=onerroreventhandlernonnull>OnErrorEventHandlerNonNull</dfn> = any ((<a href=#event>Event</a> or DOMString) event, optional DOMString source, optional unsigned long lineno, optional unsigned long column);
typedef <a href=#onerroreventhandlernonnull>OnErrorEventHandlerNonNull</a>? <dfn id=onerroreventhandler>OnErrorEventHandler</dfn>;</pre>

<p>Similarly, the <code title=handler-window-onbeforeunload><a href=#handler-window-onbeforeunload>onbeforeunload</a></code> handler has a
different return value:</p>

<pre class=idl>[TreatNonCallableAsNull]
callback <dfn id=onbeforeunloadeventhandlernonnull>OnBeforeUnloadEventHandlerNonNull</dfn> = DOMString (<a href=#event>Event</a> event);
typedef <a href=#onbeforeunloadeventhandlernonnull>OnBeforeUnloadEventHandlerNonNull</a>? <dfn id=onbeforeunloadeventhandler>OnBeforeUnloadEventHandler</dfn>;</pre>

<!-- onreadystatechange is also defined specially, using [LenientThis]; see IDL -->


Expand Down Expand Up @@ -72017,7 +72035,7 @@ interface <dfn id=globaleventhandlers>GlobalEventHandlers</dfn> {
interface <dfn id=windoweventhandlers>WindowEventHandlers</dfn> {
attribute <a href=#eventhandler>EventHandler</a> <a href=#handler-window-onafterprint title=handler-window-onafterprint>onafterprint</a>;
attribute <a href=#eventhandler>EventHandler</a> <a href=#handler-window-onbeforeprint title=handler-window-onbeforeprint>onbeforeprint</a>;
attribute <a href=#eventhandler>EventHandler</a> <a href=#handler-window-onbeforeunload title=handler-window-onbeforeunload>onbeforeunload</a>;
attribute <a href=#onbeforeunloadeventhandler>OnBeforeUnloadEventHandler</a> <a href=#handler-window-onbeforeunload title=handler-window-onbeforeunload>onbeforeunload</a>;
attribute <a href=#eventhandler>EventHandler</a> <a href=#handler-window-onhashchange title=handler-window-onhashchange>onhashchange</a>;
attribute <a href=#eventhandler>EventHandler</a> <a href=#handler-window-onmessage title=handler-window-onmessage>onmessage</a>;
attribute <a href=#eventhandler>EventHandler</a> <a href=#handler-window-onoffline title=handler-window-onoffline>onoffline</a>;
Expand Down
36 changes: 27 additions & 9 deletions source
@@ -1,4 +1,4 @@
<!-- EDITOR NOTES -*- mode: Text; fill-column: 100 -*-
<!-- EDITOR NOTES -*- mode: Text; fill-column: 100 -*-
!
! Adding a new element involves editing the following sections:
! - section for the element itself
Expand Down Expand Up @@ -80284,14 +80284,25 @@ currently this is unnecessary: http://www.w3.org/Bugs/Public/show_bug.cgi?id=119

<dd><p>If <var title="">return value</var> is a WebIDL boolean true value, then cancel the event.</p></dd>

<dt>If the <code>Event</code> object <var title="">E</var> is a <code>BeforeUnloadEvent</code>
object</dt>

<dd><p>If <var title="">return value</var> is a WebIDL string value, and the <code>Event</code> object <var
title="">E</var>'s <code title="dom-BeforeUnloadEvent-returnValue">returnValue</code>
attribute's value is the empty string, then set the <code
title="dom-BeforeUnloadEvent-returnValue">returnValue</code> attribute's value to <var
title="">return value</var>.</p></dd>
<dt>If the event type is <code class="event-beforeunload">beforeunload</code></dt>

<dd>

<p class="note">The <span>event handler IDL attribute</span>'s type is
<code>OnBeforeUnloadEventHandler</code>, and the <var title="">return value</var> will
therefore have been coerced into either the value null or a DOMString.</p>

<p>If the <var title="">return value</var> is null, then cancel the event.</p>

<p>Otherwise, If the <code>Event</code> object <var title="">E</var> is a
<code>BeforeUnloadEvent</code> object, and the <code>Event</code> object <var
title="">E</var>'s <code title="dom-BeforeUnloadEvent-returnValue">returnValue</code>
attribute's value is the empty string, then set the <code
title="dom-BeforeUnloadEvent-returnValue">returnValue</code> attribute's value to <var
title="">return value</var>.</p>

</dd>

<dt>Otherwise</dt>

Expand Down Expand Up @@ -80343,6 +80354,13 @@ typedef <span>EventHandlerNonNull</span>? <dfn>EventHandler</dfn>;</pre>
callback <dfn>OnErrorEventHandlerNonNull</dfn> = any ((<span>Event</span> or DOMString) event, optional DOMString source, optional unsigned long lineno, optional unsigned long column);
typedef <span>OnErrorEventHandlerNonNull</span>? <dfn>OnErrorEventHandler</dfn>;</pre>

<p>Similarly, the <code title="handler-window-onbeforeunload">onbeforeunload</code> handler has a
different return value:</p>

<pre class="idl">[TreatNonCallableAsNull]
callback <dfn>OnBeforeUnloadEventHandlerNonNull</dfn> = DOMString (<span>Event</span> event);
typedef <span>OnBeforeUnloadEventHandlerNonNull</span>? <dfn>OnBeforeUnloadEventHandler</dfn>;</pre>

<!-- onreadystatechange is also defined specially, using [LenientThis]; see IDL -->


Expand Down Expand Up @@ -80571,7 +80589,7 @@ interface <dfn>GlobalEventHandlers</dfn> {
interface <dfn>WindowEventHandlers</dfn> {
attribute <span>EventHandler</span> <span title="handler-window-onafterprint">onafterprint</span>;
attribute <span>EventHandler</span> <span title="handler-window-onbeforeprint">onbeforeprint</span>;
attribute <span>EventHandler</span> <span title="handler-window-onbeforeunload">onbeforeunload</span>;
attribute <span>OnBeforeUnloadEventHandler</span> <span title="handler-window-onbeforeunload">onbeforeunload</span>;
attribute <span>EventHandler</span> <span title="handler-window-onhashchange">onhashchange</span>;
attribute <span>EventHandler</span> <span title="handler-window-onmessage">onmessage</span>;
attribute <span>EventHandler</span> <span title="handler-window-onoffline">onoffline</span>;
Expand Down

0 comments on commit 7612afe

Please sign in to comment.