Skip to content

Commit 049dd58

Browse files
git squash commit for cursor-close.
442fb99 Sketch out IDBCursor.close() 343d7dd rebased and updated
1 parent bb2eb85 commit 049dd58

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
@@ -4284,6 +4284,7 @@ interface IDBCursor {
42844284
undefined advance([EnforceRange] unsigned long count);
42854285
undefined continue(optional any key);
42864286
undefined continuePrimaryKey(any key, any primaryKey);
4287+
undefined close();
42874288

42884289
[NewObject] IDBRequest update(any value);
42894290
[NewObject] IDBRequest delete();
@@ -4329,7 +4330,8 @@ return [=/this=]'s [=cursor/source=].
43294330

43304331
<aside class=note>
43314332
The {{IDBCursor/source}} attribute never returns null or throws an exception, even if the
4332-
cursor is currently being iterated, has iterated past its end, or its
4333+
cursor is currently being iterated, has iterated past its end,
4334+
{{IDBCursor/close()}} has been called, or its
43334335
[=/transaction=] is not [=transaction/active=].
43344336
</aside>
43354337

@@ -4406,6 +4408,12 @@ return [=/this=]'s [=cursor/request=].
44064408
Advances the cursor to the next [=object-store/record=] in range matching
44074409
or after |key| and |primaryKey|. Throws an "{{InvalidAccessError}}" {{DOMException}}
44084410
if the [=cursor/source=] is not an [=/index=].
4411+
4412+
4413+
: |cursor| . {{IDBCursor/close()|close}}()
4414+
::
4415+
Signals that the cursor is no longer needed, and that any associated resources can be released.
4416+
44094417
</div>
44104418

44114419

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

4427-
1. If [=/this=]'s [=cursor/got value flag=] is false, indicating that
4428-
the cursor is being iterated or has iterated past its end,
4429-
[=exception/throw=] an "{{InvalidStateError}}" {{DOMException}}.
4435+
1. If [=/this=]'s [=cursor/got value flag=] is false
4436+
(indicating that the cursor is being iterated, has iterated past its end, or that {{IDBCursor/close()}} was called),
4437+
then [=exception/throw=] an "{{InvalidStateError}}" {{DOMException}}.
44304438

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

@@ -4464,9 +4472,9 @@ The <dfn method for=IDBCursor>continue(|key|)</dfn> method steps are:
44644472
[=cursor/effective object store=] has been deleted, [=exception/throw=] an
44654473
"{{InvalidStateError}}" {{DOMException}}.
44664474

4467-
1. If [=/this=]'s [=cursor/got value flag=] is false, indicating that
4468-
the cursor is being iterated or has iterated past its end,
4469-
[=exception/throw=] an "{{InvalidStateError}}" {{DOMException}}.
4475+
1. If [=/this=]'s [=cursor/got value flag=] is false
4476+
(indicating that the cursor is being iterated, has iterated past its end, or that {{IDBCursor/close()}} was called),
4477+
then [=exception/throw=] an "{{InvalidStateError}}" {{DOMException}}.
44704478

44714479
1. If |key| is given, then:
44724480

@@ -4526,9 +4534,9 @@ The <dfn method for=IDBCursor>continuePrimaryKey(|key|, |primaryKey|)</dfn> meth
45264534
1. If [=/this=]'s [=cursor/direction=] is not "{{IDBCursorDirection/next}}" or "{{IDBCursorDirection/prev}}",
45274535
[=exception/throw=] an "{{InvalidAccessError}}" {{DOMException}}.
45284536

4529-
1. If [=/this=]'s [=cursor/got value flag=] is false, indicating that
4530-
the cursor is being iterated or has iterated past its end,
4531-
[=exception/throw=] an "{{InvalidStateError}}" {{DOMException}}.
4537+
1. If [=/this=]'s [=cursor/got value flag=] is false
4538+
(indicating that the cursor is being iterated, has iterated past its end, or that {{IDBCursor/close()}} was called),
4539+
then [=exception/throw=] an "{{InvalidStateError}}" {{DOMException}}.
45324540

45334541
1. Let |r| be the result of [=/converting a value to
45344542
a key=] with |key|. Rethrow any exceptions.
@@ -4585,6 +4593,39 @@ The <dfn method for=IDBCursor>continuePrimaryKey(|key|, |primaryKey|)</dfn> meth
45854593
flag=] has been set to false.
45864594
</aside>
45874595

4596+
<div algorithm>
4597+
4598+
The <dfn method for=IDBCursor>close()</dfn> method steps are:
4599+
4600+
1. Let |transaction| be [=/this=]'s [=cursor/transaction=].
4601+
4602+
1. If |transaction|'s [=transaction/state=] is not [=transaction/active=], then [=exception/throw=] a "{{TransactionInactiveError}}" {{DOMException}}.
4603+
4604+
1. If [=/this=]'s [=cursor/source=] or [=cursor/effective object store=] has been deleted, then [=exception/throw=] an "{{InvalidStateError}}" {{DOMException}}.
4605+
4606+
1. If [=/this=]'s [=cursor/got value flag=] is false
4607+
(indicating that the cursor is being iterated, has iterated past its end, or that {{IDBCursor/close()}} was called),
4608+
then [=exception/throw=] an "{{InvalidStateError}}" {{DOMException}}.
4609+
4610+
1. Set [=/this=]'s [=cursor/got value flag=] to false.
4611+
4612+
1. Set [=/this=]'s [=cursor/key=] to undefined.
4613+
4614+
1. If [=/this=]'s [=cursor/source=] is an [=/index=], then set [=/this=]'s [=cursor/object store position=] to undefined.
4615+
4616+
1. If [=/this=]'s [=cursor/key only flag=] is false, then set [=/this=]'s [=cursor/value=] to undefined.
4617+
4618+
</div>
4619+
4620+
<aside class=note>
4621+
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.
4622+
</aside>
4623+
4624+
<aside class=advisement>
4625+
&#x1F6A7;
4626+
The {{IDBCursor/close()}} method is new in this edition.
4627+
&#x1F6A7;
4628+
</aside>
45884629

45894630

45904631
<div class="domintro note">
@@ -4628,9 +4669,9 @@ The <dfn method for=IDBCursor>update(|value|)</dfn> method steps are:
46284669
1. If [=/this=]'s [=cursor/source=] or [=cursor/effective object
46294670
store=] has been deleted, [=exception/throw=] an "{{InvalidStateError}}" {{DOMException}}.
46304671

4631-
1. If [=/this=]'s [=cursor/got value flag=] is false, indicating that
4632-
the cursor is being iterated or has iterated past its end,
4633-
[=exception/throw=] an "{{InvalidStateError}}" {{DOMException}}.
4672+
1. If [=/this=]'s [=cursor/got value flag=] is false
4673+
(indicating that the cursor is being iterated, has iterated past its end, or that {{IDBCursor/close()}} was called),
4674+
then [=exception/throw=] an "{{InvalidStateError}}" {{DOMException}}.
46344675

46354676
1. If [=/this=]'s [=cursor/key only flag=] is true, [=exception/throw=] an
46364677
"{{InvalidStateError}}" {{DOMException}}.
@@ -4689,9 +4730,9 @@ The <dfn method for=IDBCursor>delete()</dfn> method steps are:
46894730
1. If [=/this=]'s [=cursor/source=] or [=cursor/effective object
46904731
store=] has been deleted, [=exception/throw=] an "{{InvalidStateError}}" {{DOMException}}.
46914732

4692-
1. If [=/this=]'s [=cursor/got value flag=] is false, indicating that
4693-
the cursor is being iterated or has iterated past its end,
4694-
[=exception/throw=] an "{{InvalidStateError}}" {{DOMException}}.
4733+
1. If [=/this=]'s [=cursor/got value flag=] is false
4734+
(indicating that the cursor is being iterated, has iterated past its end, or that {{IDBCursor/close()}} was called),
4735+
then [=exception/throw=] an "{{InvalidStateError}}" {{DOMException}}.
46954736

46964737
1. If [=/this=]'s [=cursor/key only flag=] is true, [=exception/throw=] an
46974738
"{{InvalidStateError}}" {{DOMException}}.
@@ -6805,6 +6846,7 @@ For the revision history of the second edition, see [that document's Revision Hi
68056846
* 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))
68066847
* Added <a href="#accessibility">Accessibility considerations</a> section. ([Issue #327](https://github.com/w3c/IndexedDB/issues/327))
68076848
* Used [[infra]]'s list sorting definition. ([Issue #346](https://github.com/w3c/IndexedDB/issues/346))
6849+
* Added {{IDBCursor/close()}} method for {{IDBCursor}}. ([Issue #185](https://github.com/w3c/IndexedDB/issues/185))
68086850

68096851
<!-- ============================================================ -->
68106852
# Acknowledgements # {#acknowledgements}

0 commit comments

Comments
 (0)