Skip to content

Commit 9bede8a

Browse files
git squash commit for cursor-close.
442fb99 Sketch out IDBCursor.close() 343d7dd rebased and updated
1 parent 22382f6 commit 9bede8a

File tree

1 file changed

+58
-16
lines changed

1 file changed

+58
-16
lines changed

index.bs

Lines changed: 58 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4280,6 +4280,7 @@ interface IDBCursor {
42804280
undefined advance([EnforceRange] unsigned long count);
42814281
undefined continue(optional any key);
42824282
undefined continuePrimaryKey(any key, any primaryKey);
4283+
undefined close();
42834284

42844285
[NewObject] IDBRequest update(any value);
42854286
[NewObject] IDBRequest delete();
@@ -4325,7 +4326,8 @@ return [=/this=]'s [=cursor/source=].
43254326

43264327
<aside class=note>
43274328
The {{IDBCursor/source}} attribute never returns null or throws an exception, even if the
4328-
cursor is currently being iterated, has iterated past its end, or its
4329+
cursor is currently being iterated, has iterated past its end,
4330+
{{IDBCursor/close()}} has been called, or its
43294331
[=/transaction=] is not [=transaction/active=].
43304332
</aside>
43314333

@@ -4402,6 +4404,12 @@ return [=/this=]'s [=cursor/request=].
44024404
Advances the cursor to the next [=object-store/record=] in range matching
44034405
or after |key| and |primaryKey|. Throws an "{{InvalidAccessError}}" {{DOMException}}
44044406
if the [=cursor/source=] is not an [=/index=].
4407+
4408+
4409+
: |cursor| . {{IDBCursor/close()|close}}()
4410+
::
4411+
Signals that the cursor is no longer needed, and that any associated resources can be released.
4412+
44054413
</div>
44064414

44074415

@@ -4420,9 +4428,9 @@ The <dfn method for=IDBCursor>advance(|count|)</dfn> method steps are:
44204428
1. If [=/this=]'s [=cursor/source=] or [=effective object
44214429
store=] has been deleted, [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
44224430

4423-
1. If [=/this=]'s [=cursor/got value flag=] is false, indicating that
4424-
the cursor is being iterated or has iterated past its end,
4425-
[=throw=] an "{{InvalidStateError}}" {{DOMException}}.
4431+
1. If [=/this=]'s [=cursor/got value flag=] is false
4432+
(indicating that the cursor is being iterated, has iterated past its end, or that {{IDBCursor/close()}} was called),
4433+
then [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
44264434

44274435
1. Set [=/this=]'s [=cursor/got value flag=] to false.
44284436

@@ -4460,9 +4468,9 @@ The <dfn method for=IDBCursor>continue(|key|)</dfn> method steps are:
44604468
[=effective object store=] has been deleted, [=throw=] an
44614469
"{{InvalidStateError}}" {{DOMException}}.
44624470

4463-
1. If [=/this=]'s [=cursor/got value flag=] is false, indicating that
4464-
the cursor is being iterated or has iterated past its end,
4465-
[=throw=] an "{{InvalidStateError}}" {{DOMException}}.
4471+
1. If [=/this=]'s [=cursor/got value flag=] is false
4472+
(indicating that the cursor is being iterated, has iterated past its end, or that {{IDBCursor/close()}} was called),
4473+
then [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
44664474

44674475
1. If |key| is given, then:
44684476

@@ -4522,9 +4530,9 @@ The <dfn method for=IDBCursor>continuePrimaryKey(|key|, |primaryKey|)</dfn> meth
45224530
1. If [=/this=]'s [=cursor/direction=] is not {{"next"}} or {{"prev"}},
45234531
[=throw=] an "{{InvalidAccessError}}" {{DOMException}}.
45244532

4525-
1. If [=/this=]'s [=cursor/got value flag=] is false, indicating that
4526-
the cursor is being iterated or has iterated past its end,
4527-
[=throw=] an "{{InvalidStateError}}" {{DOMException}}.
4533+
1. If [=/this=]'s [=cursor/got value flag=] is false
4534+
(indicating that the cursor is being iterated, has iterated past its end, or that {{IDBCursor/close()}} was called),
4535+
then [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
45284536

45294537
1. Let |r| be the result of [=/converting a value to
45304538
a key=] with |key|. Rethrow any exceptions.
@@ -4581,6 +4589,39 @@ The <dfn method for=IDBCursor>continuePrimaryKey(|key|, |primaryKey|)</dfn> meth
45814589
flag=] has been set to false.
45824590
</aside>
45834591

4592+
<div algorithm>
4593+
4594+
The <dfn method for=IDBCursor>close()</dfn> method steps are:
4595+
4596+
1. Let |transaction| be [=/this=]'s [=cursor/transaction=].
4597+
4598+
1. If |transaction|'s [=transaction/state=] is not [=transaction/active=], then [=throw=] a "{{TransactionInactiveError}}" {{DOMException}}.
4599+
4600+
1. If [=/this=]'s [=cursor/source=] or [=effective object store=] has been deleted, then [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
4601+
4602+
1. If [=/this=]'s [=cursor/got value flag=] is false
4603+
(indicating that the cursor is being iterated, has iterated past its end, or that {{IDBCursor/close()}} was called),
4604+
then [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
4605+
4606+
1. Set [=/this=]'s [=cursor/got value flag=] to false.
4607+
4608+
1. Set [=/this=]'s [=cursor/key=] to undefined.
4609+
4610+
1. If [=/this=]'s [=cursor/source=] is an [=/index=], then set [=/this=]'s [=object store position=] to undefined.
4611+
4612+
1. If [=/this=]'s [=cursor/key only flag=] is false, then set [=/this=]'s [=cursor/value=] to undefined.
4613+
4614+
</div>
4615+
4616+
<aside class=note>
4617+
The {{IDBCursor/close()}} method allows web applications to hint to the user agent that the cursor will no longer be iterated, and that any state associated with the cursor can be discarded.
4618+
</aside>
4619+
4620+
<aside class=advisement>
4621+
&#x1F6A7;
4622+
The {{IDBCursor/close()}} method is new in this edition.
4623+
&#x1F6A7;
4624+
</aside>
45844625

45854626

45864627
<div class="domintro note">
@@ -4624,9 +4665,9 @@ The <dfn method for=IDBCursor>update(|value|)</dfn> method steps are:
46244665
1. If [=/this=]'s [=cursor/source=] or [=effective object
46254666
store=] has been deleted, [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
46264667

4627-
1. If [=/this=]'s [=cursor/got value flag=] is false, indicating that
4628-
the cursor is being iterated or has iterated past its end,
4629-
[=throw=] an "{{InvalidStateError}}" {{DOMException}}.
4668+
1. If [=/this=]'s [=cursor/got value flag=] is false
4669+
(indicating that the cursor is being iterated, has iterated past its end, or that {{IDBCursor/close()}} was called),
4670+
then [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
46304671

46314672
1. If [=/this=]'s [=cursor/key only flag=] is true, [=throw=] an
46324673
"{{InvalidStateError}}" {{DOMException}}.
@@ -4685,9 +4726,9 @@ The <dfn method for=IDBCursor>delete()</dfn> method steps are:
46854726
1. If [=/this=]'s [=cursor/source=] or [=effective object
46864727
store=] has been deleted, [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
46874728

4688-
1. If [=/this=]'s [=cursor/got value flag=] is false, indicating that
4689-
the cursor is being iterated or has iterated past its end,
4690-
[=throw=] an "{{InvalidStateError}}" {{DOMException}}.
4729+
1. If [=/this=]'s [=cursor/got value flag=] is false
4730+
(indicating that the cursor is being iterated, has iterated past its end, or that {{IDBCursor/close()}} was called),
4731+
then [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
46914732

46924733
1. If [=/this=]'s [=cursor/key only flag=] is true, [=throw=] an
46934734
"{{InvalidStateError}}" {{DOMException}}.
@@ -6801,6 +6842,7 @@ For the revision history of the second edition, see [that document's Revision Hi
68016842
* Specified [[#transaction-scheduling]] more precisely and disallow starting read/write transactions while read-only transactions with overlapping scope are running. ([Issue #253](https://github.com/w3c/IndexedDB/issues/253))
68026843
* Added <a href="#accessibility">Accessibility considerations</a> section. ([Issue #327](https://github.com/w3c/IndexedDB/issues/327))
68036844
* Used [[infra]]'s list sorting definition. ([Issue #346](https://github.com/w3c/IndexedDB/issues/346))
6845+
* Added {{IDBCursor/close()}} method for {{IDBCursor}}. ([Issue #185](https://github.com/w3c/IndexedDB/issues/185))
68046846

68056847
<!-- ============================================================ -->
68066848
# Acknowledgements # {#acknowledgements}

0 commit comments

Comments
 (0)