Skip to content
Permalink
Browse files

[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 7612afe2f2d13939094811b4f42000edede24069
Showing with 75 additions and 21 deletions.
  1. +24 −6 complete.html
  2. +24 −6 index
  3. +27 −9 source

<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>

<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>

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 -->


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>;
30 index

<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>

<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>

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 -->


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>;
36 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

<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>

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 -->


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>;

0 comments on commit 7612afe

Please sign in to comment.
You can’t perform that action at this time.