Skip to content

Commit 82dd422

Browse files
Clarify firing of events after open/deleteDatabase calls. Resolves #79
1 parent d1147cb commit 82dd422

File tree

2 files changed

+76
-67
lines changed

2 files changed

+76
-67
lines changed

index.bs

Lines changed: 47 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1974,37 +1974,38 @@ when invoked, must run these steps:
19741974
<a for=database>version</a> equal to 1.
19751975
</aside>
19761976

1977-
2. If |result| is an error, set the <a
1978-
for=request>error</a> of |request| to
1979-
|result| and dispatch an event at |request|.
1980-
The event must use the <a>Event</a> interface and set the
1981-
{{Event/type}} attribute to "<code>error</code>". The event
1982-
does bubble but is not cancelable.
1983-
1984-
3. Otherwise, set the <a for=request>result</a> of
1985-
|request| to |result| and dispatch an event
1986-
at |request|. The event must use the <a>Event</a>
1987-
interface and set the {{Event/type}} attribute to
1988-
"<code>success</code>". The event does not bubble and is not
1989-
cancelable. If the steps above resulted in an <a>upgrade
1990-
transaction</a> being run, then firing the
1991-
"<code>success</code>" event must be done after the <a>upgrade
1992-
transaction</a> completes.
1977+
2. <a>Queue a task</a> to run these substeps:
1978+
1979+
1. If |result| is an error, set the <a for=request>error</a>
1980+
of |request| to |result| and dispatch an event at
1981+
|request|. The event must use the <a>Event</a> interface
1982+
and set the {{Event/type}} attribute to
1983+
"<code>error</code>". The event does bubble but is not
1984+
cancelable.
1985+
1986+
2. Otherwise, set the <a for=request>result</a> of |request|
1987+
to |result| and dispatch an event at |request|. The event
1988+
must use the <a>Event</a> interface and set the
1989+
{{Event/type}} attribute to "<code>success</code>". The
1990+
event does not bubble and is not cancelable. If the steps
1991+
above resulted in an <a>upgrade transaction</a> being run,
1992+
then firing the "<code>success</code>" event must be done
1993+
after the <a>upgrade transaction</a> completes.
19931994

1994-
<aside class=note>
1995-
The last requirement is to ensure that in case another
1996-
version upgrade is about to happen, the success event is
1997-
fired on the connection first so that the script gets a
1998-
chance to register a listener for the
1999-
<code>versionchange</code> event.
2000-
</aside>
1995+
<aside class=note>
1996+
The last requirement is to ensure that in case another
1997+
version upgrade is about to happen, the success event is
1998+
fired on the connection first so that the script gets a
1999+
chance to register a listener for the
2000+
<code>versionchange</code> event.
2001+
</aside>
20012002

2002-
<aside class=note>
2003-
The firing of "<code>success</code>" or "<code>error</code>"
2004-
events do not follow the normal steps to <a>fire a success
2005-
event</a> or <a>fire an error event</a> as there is no
2006-
active transaction at the time when they fire.
2007-
</aside>
2003+
<aside class=note>
2004+
The firing of "<code>success</code>" or "<code>error</code>"
2005+
events do not follow the normal steps to <a>fire a success
2006+
event</a> or <a>fire an error event</a> as there is no
2007+
active transaction at the time when they fire.
2008+
</aside>
20082009

20092010
4. Return a new {{IDBOpenDBRequest}} object for |request|.
20102011

@@ -2017,31 +2018,31 @@ when invoked, must run these steps:
20172018

20182019
1. Let |request| be a new <a>open request</a>.
20192020

2020-
2. <a>Queue a task</a> to run these substeps:
2021+
3. Run the following substeps in parallel:
20212022

20222023
1. Let |result| be the result of running the <a>steps for
20232024
deleting a database</a>, with the origin of the
20242025
{{IDBEnvironment}} used to access this {{IDBFactory}},
20252026
|name|, and |request|.
20262027

2027-
2. If |result| is an error set the <a
2028-
for=request>error</a> of |request| to
2029-
|result| and dispatch an event at |request|.
2030-
The event must use the <a>Event</a> interface and set the
2031-
{{Event/type}} attribute to "<code>error</code>". The event
2032-
does bubble but is not cancelable.
2028+
2. <a>Queue a task</a> to run these substeps:
2029+
1. If |result| is an error set the <a for=request>error</a> of
2030+
|request| to |result| and dispatch an event at |request|.
2031+
The event must use the <a>Event</a> interface and set the
2032+
{{Event/type}} attribute to "<code>error</code>". The
2033+
event does bubble but is not cancelable.
20332034

2034-
3. Otherwise, set the <a for=request>result</a> of
2035-
|request| to undefined and <a>fire a version change
2036-
event</a> named <code>success</code> at <a>request</a> with
2037-
|result| and null.
2035+
2. Otherwise, set the <a for=request>result</a> of |request|
2036+
to undefined and <a>fire a version change event</a> named
2037+
<code>success</code> at <a>request</a> with |result| and
2038+
null.
20382039

2039-
<aside class=note>
2040-
The firing of "<code>success</code>" or "<code>error</code>"
2041-
events do not follow the normal steps to <a>fire a success
2042-
event</a> or <a>fire an error event</a> as there is no
2043-
active transaction at the time when they fire.
2044-
</aside>
2040+
<aside class=note>
2041+
The firing of "<code>success</code>" or "<code>error</code>"
2042+
events do not follow the normal steps to <a>fire a success
2043+
event</a> or <a>fire an error event</a> as there is no
2044+
active transaction at the time when they fire.
2045+
</aside>
20452046

20462047
3. Return a new {{IDBOpenDBRequest}} object for |request|.
20472048

index.html

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2917,25 +2917,29 @@ <h3 class="heading settled" data-level="4.3" id="factory-interface"><span class=
29172917
without changing the <a data-link-type="dfn" href="#database-version" id="ref-for-database-version-6">version</a>. If <var>version</var> is not given and no <a data-link-type="dfn" href="#database" id="ref-for-database-31">database</a> with
29182918
that name exists, a new <a data-link-type="dfn" href="#database" id="ref-for-database-32">database</a> will be created with <a data-link-type="dfn" href="#database-version" id="ref-for-database-version-7">version</a> equal to 1. </aside>
29192919
<li data-md="">
2920-
<p>If <var>result</var> is an error, set the <a data-link-type="dfn" href="#request-error" id="ref-for-request-error-3">error</a> of <var>request</var> to <var>result</var> and dispatch an event at <var>request</var>.
2921-
The event must use the <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#concept-event">Event</a> interface and set the <code class="idl"><a data-link-type="idl" href="https://dom.spec.whatwg.org/#dom-event-type">type</a></code> attribute to "<code>error</code>". The event
2922-
does bubble but is not cancelable.</p>
2923-
<li data-md="">
2924-
<p>Otherwise, set the <a data-link-type="dfn" href="#request-result" id="ref-for-request-result-4">result</a> of <var>request</var> to <var>result</var> and dispatch an event
2925-
at <var>request</var>. The event must use the <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#concept-event">Event</a> interface and set the <code class="idl"><a data-link-type="idl" href="https://dom.spec.whatwg.org/#dom-event-type">type</a></code> attribute to
2926-
"<code>success</code>". The event does not bubble and is not
2927-
cancelable. If the steps above resulted in an <a data-link-type="dfn" href="#upgrade-transaction" id="ref-for-upgrade-transaction-14">upgrade
2928-
transaction</a> being run, then firing the
2929-
"<code>success</code>" event must be done after the <a data-link-type="dfn" href="#upgrade-transaction" id="ref-for-upgrade-transaction-15">upgrade
2930-
transaction</a> completes.</p>
2931-
<aside class="note" role="note"> The last requirement is to ensure that in case another
2920+
<p><a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#queue-a-task">Queue a task</a> to run these substeps:</p>
2921+
<ol>
2922+
<li data-md="">
2923+
<p>If <var>result</var> is an error, set the <a data-link-type="dfn" href="#request-error" id="ref-for-request-error-3">error</a> of <var>request</var> to <var>result</var> and dispatch an event at <var>request</var>. The event must use the <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#concept-event">Event</a> interface
2924+
and set the <code class="idl"><a data-link-type="idl" href="https://dom.spec.whatwg.org/#dom-event-type">type</a></code> attribute to
2925+
"<code>error</code>". The event does bubble but is not
2926+
cancelable.</p>
2927+
<li data-md="">
2928+
<p>Otherwise, set the <a data-link-type="dfn" href="#request-result" id="ref-for-request-result-4">result</a> of <var>request</var> to <var>result</var> and dispatch an event at <var>request</var>. The event
2929+
must use the <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#concept-event">Event</a> interface and set the <code class="idl"><a data-link-type="idl" href="https://dom.spec.whatwg.org/#dom-event-type">type</a></code> attribute to "<code>success</code>". The
2930+
event does not bubble and is not cancelable. If the steps
2931+
above resulted in an <a data-link-type="dfn" href="#upgrade-transaction" id="ref-for-upgrade-transaction-14">upgrade transaction</a> being run,
2932+
then firing the "<code>success</code>" event must be done
2933+
after the <a data-link-type="dfn" href="#upgrade-transaction" id="ref-for-upgrade-transaction-15">upgrade transaction</a> completes.</p>
2934+
<aside class="note" role="note"> The last requirement is to ensure that in case another
29322935
version upgrade is about to happen, the success event is
29332936
fired on the connection first so that the script gets a
29342937
chance to register a listener for the <code>versionchange</code> event. </aside>
2935-
<aside class="note" role="note"> The firing of "<code>success</code>" or "<code>error</code>"
2938+
<aside class="note" role="note"> The firing of "<code>success</code>" or "<code>error</code>"
29362939
events do not follow the normal steps to <a data-link-type="dfn" href="#request-fire-a-success-event" id="ref-for-request-fire-a-success-event-1">fire a success
29372940
event</a> or <a data-link-type="dfn" href="#request-fire-an-error-event" id="ref-for-request-fire-an-error-event-1">fire an error event</a> as there is no
29382941
active transaction at the time when they fire. </aside>
2942+
</ol>
29392943
</ol>
29402944
<li data-md="">
29412945
<p>Return a new <code class="idl"><a data-link-type="idl" href="#request-idbopendbrequest" id="ref-for-request-idbopendbrequest-3">IDBOpenDBRequest</a></code> object for <var>request</var>.</p>
@@ -2948,22 +2952,26 @@ <h3 class="heading settled" data-level="4.3" id="factory-interface"><span class=
29482952
<li data-md="">
29492953
<p>Let <var>request</var> be a new <a data-link-type="dfn" href="#request-open-request" id="ref-for-request-open-request-12">open request</a>.</p>
29502954
<li data-md="">
2951-
<p><a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#queue-a-task">Queue a task</a> to run these substeps:</p>
2955+
<p>Run the following substeps in parallel:</p>
29522956
<ol>
29532957
<li data-md="">
29542958
<p>Let <var>result</var> be the result of running the <a data-link-type="dfn" href="#request-steps-for-deleting-a-database" id="ref-for-request-steps-for-deleting-a-database-1">steps for
29552959
deleting a database</a>, with the origin of the <code class="idl"><a data-link-type="idl" href="#request-idbenvironment" id="ref-for-request-idbenvironment-4">IDBEnvironment</a></code> used to access this <code class="idl"><a data-link-type="idl" href="#request-idbfactory" id="ref-for-request-idbfactory-5">IDBFactory</a></code>, <var>name</var>, and <var>request</var>.</p>
29562960
<li data-md="">
2957-
<p>If <var>result</var> is an error set the <a data-link-type="dfn" href="#request-error" id="ref-for-request-error-4">error</a> of <var>request</var> to <var>result</var> and dispatch an event at <var>request</var>.
2958-
The event must use the <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#concept-event">Event</a> interface and set the <code class="idl"><a data-link-type="idl" href="https://dom.spec.whatwg.org/#dom-event-type">type</a></code> attribute to "<code>error</code>". The event
2959-
does bubble but is not cancelable.</p>
2960-
<li data-md="">
2961-
<p>Otherwise, set the <a data-link-type="dfn" href="#request-result" id="ref-for-request-result-5">result</a> of <var>request</var> to undefined and <a data-link-type="dfn" href="#request-fire-a-version-change-event" id="ref-for-request-fire-a-version-change-event-1">fire a version change
2962-
event</a> named <code>success</code> at <a data-link-type="dfn" href="#request" id="ref-for-request-20">request</a> with <var>result</var> and null.</p>
2963-
<aside class="note" role="note"> The firing of "<code>success</code>" or "<code>error</code>"
2961+
<p><a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#queue-a-task">Queue a task</a> to run these substeps:</p>
2962+
<ol>
2963+
<li data-md="">
2964+
<p>If <var>result</var> is an error set the <a data-link-type="dfn" href="#request-error" id="ref-for-request-error-4">error</a> of <var>request</var> to <var>result</var> and dispatch an event at <var>request</var>.
2965+
The event must use the <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#concept-event">Event</a> interface and set the <code class="idl"><a data-link-type="idl" href="https://dom.spec.whatwg.org/#dom-event-type">type</a></code> attribute to "<code>error</code>". The
2966+
event does bubble but is not cancelable.</p>
2967+
<li data-md="">
2968+
<p>Otherwise, set the <a data-link-type="dfn" href="#request-result" id="ref-for-request-result-5">result</a> of <var>request</var> to undefined and <a data-link-type="dfn" href="#request-fire-a-version-change-event" id="ref-for-request-fire-a-version-change-event-1">fire a version change event</a> named <code>success</code> at <a data-link-type="dfn" href="#request" id="ref-for-request-20">request</a> with <var>result</var> and
2969+
null.</p>
2970+
<aside class="note" role="note"> The firing of "<code>success</code>" or "<code>error</code>"
29642971
events do not follow the normal steps to <a data-link-type="dfn" href="#request-fire-a-success-event" id="ref-for-request-fire-a-success-event-2">fire a success
29652972
event</a> or <a data-link-type="dfn" href="#request-fire-an-error-event" id="ref-for-request-fire-an-error-event-2">fire an error event</a> as there is no
29662973
active transaction at the time when they fire. </aside>
2974+
</ol>
29672975
</ol>
29682976
<li data-md="">
29692977
<p>Return a new <code class="idl"><a data-link-type="idl" href="#request-idbopendbrequest" id="ref-for-request-idbopendbrequest-4">IDBOpenDBRequest</a></code> object for <var>request</var>.</p>

0 commit comments

Comments
 (0)