Skip to content

Commit 12abb78

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

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
@@ -4261,6 +4261,7 @@ interface IDBCursor {
42614261
undefined advance([EnforceRange] unsigned long count);
42624262
undefined continue(optional any key);
42634263
undefined continuePrimaryKey(any key, any primaryKey);
4264+
undefined close();
42644265

42654266
[NewObject] IDBRequest update(any value);
42664267
[NewObject] IDBRequest delete();
@@ -4306,7 +4307,8 @@ return [=/this=]'s [=cursor/source=].
43064307

43074308
<aside class=note>
43084309
The {{IDBCursor/source}} attribute never returns null or throws an exception, even if the
4309-
cursor is currently being iterated, has iterated past its end, or its
4310+
cursor is currently being iterated, has iterated past its end,
4311+
{{IDBCursor/close()}} has been called, or its
43104312
[=/transaction=] is not [=transaction/active=].
43114313
</aside>
43124314

@@ -4383,6 +4385,12 @@ return [=/this=]'s [=cursor/request=].
43834385
Advances the cursor to the next [=object-store/record=] in range matching
43844386
or after |key| and |primaryKey|. Throws an "{{InvalidAccessError}}" {{DOMException}}
43854387
if the [=cursor/source=] is not an [=/index=].
4388+
4389+
4390+
: |cursor| . {{IDBCursor/close()|close}}()
4391+
::
4392+
Signals that the cursor is no longer needed, and that any associated resources can be released.
4393+
43864394
</div>
43874395

43884396

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

4404-
1. If [=/this=]'s [=cursor/got value flag=] is false, indicating that
4405-
the cursor is being iterated or has iterated past its end,
4406-
[=exception/throw=] an "{{InvalidStateError}}" {{DOMException}}.
4412+
1. If [=/this=]'s [=cursor/got value flag=] is false
4413+
(indicating that the cursor is being iterated, has iterated past its end, or that {{IDBCursor/close()}} was called),
4414+
then [=exception/throw=] an "{{InvalidStateError}}" {{DOMException}}.
44074415

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

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

4444-
1. If [=/this=]'s [=cursor/got value flag=] is false, indicating that
4445-
the cursor is being iterated or has iterated past its end,
4446-
[=exception/throw=] an "{{InvalidStateError}}" {{DOMException}}.
4452+
1. If [=/this=]'s [=cursor/got value flag=] is false
4453+
(indicating that the cursor is being iterated, has iterated past its end, or that {{IDBCursor/close()}} was called),
4454+
then [=exception/throw=] an "{{InvalidStateError}}" {{DOMException}}.
44474455

44484456
1. If |key| is given, then:
44494457

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

4506-
1. If [=/this=]'s [=cursor/got value flag=] is false, indicating that
4507-
the cursor is being iterated or has iterated past its end,
4508-
[=exception/throw=] an "{{InvalidStateError}}" {{DOMException}}.
4514+
1. If [=/this=]'s [=cursor/got value flag=] is false
4515+
(indicating that the cursor is being iterated, has iterated past its end, or that {{IDBCursor/close()}} was called),
4516+
then [=exception/throw=] an "{{InvalidStateError}}" {{DOMException}}.
45094517

45104518
1. Let |r| be the result of [=/converting a value to
45114519
a key=] with |key|. Rethrow any exceptions.
@@ -4562,6 +4570,39 @@ The <dfn method for=IDBCursor>continuePrimaryKey(|key|, |primaryKey|)</dfn> meth
45624570
flag=] has been set to false.
45634571
</aside>
45644572

4573+
<div algorithm>
4574+
4575+
The <dfn method for=IDBCursor>close()</dfn> method steps are:
4576+
4577+
1. Let |transaction| be [=/this=]'s [=cursor/transaction=].
4578+
4579+
1. If |transaction|'s [=transaction/state=] is not [=transaction/active=], then [=exception/throw=] a "{{TransactionInactiveError}}" {{DOMException}}.
4580+
4581+
1. If [=/this=]'s [=cursor/source=] or [=cursor/effective object store=] has been deleted, then [=exception/throw=] an "{{InvalidStateError}}" {{DOMException}}.
4582+
4583+
1. If [=/this=]'s [=cursor/got value flag=] is false
4584+
(indicating that the cursor is being iterated, has iterated past its end, or that {{IDBCursor/close()}} was called),
4585+
then [=exception/throw=] an "{{InvalidStateError}}" {{DOMException}}.
4586+
4587+
1. Set [=/this=]'s [=cursor/got value flag=] to false.
4588+
4589+
1. Set [=/this=]'s [=cursor/key=] to undefined.
4590+
4591+
1. If [=/this=]'s [=cursor/source=] is an [=/index=], then set [=/this=]'s [=cursor/object store position=] to undefined.
4592+
4593+
1. If [=/this=]'s [=cursor/key only flag=] is false, then set [=/this=]'s [=cursor/value=] to undefined.
4594+
4595+
</div>
4596+
4597+
<aside class=note>
4598+
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.
4599+
</aside>
4600+
4601+
<aside class=advisement>
4602+
&#x1F6A7;
4603+
The {{IDBCursor/close()}} method is new in this edition.
4604+
&#x1F6A7;
4605+
</aside>
45654606

45664607

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

4608-
1. If [=/this=]'s [=cursor/got value flag=] is false, indicating that
4609-
the cursor is being iterated or has iterated past its end,
4610-
[=exception/throw=] an "{{InvalidStateError}}" {{DOMException}}.
4649+
1. If [=/this=]'s [=cursor/got value flag=] is false
4650+
(indicating that the cursor is being iterated, has iterated past its end, or that {{IDBCursor/close()}} was called),
4651+
then [=exception/throw=] an "{{InvalidStateError}}" {{DOMException}}.
46114652

46124653
1. If [=/this=]'s [=cursor/key only flag=] is true, [=exception/throw=] an
46134654
"{{InvalidStateError}}" {{DOMException}}.
@@ -4666,9 +4707,9 @@ The <dfn method for=IDBCursor>delete()</dfn> method steps are:
46664707
1. If [=/this=]'s [=cursor/source=] or [=cursor/effective object
46674708
store=] has been deleted, [=exception/throw=] an "{{InvalidStateError}}" {{DOMException}}.
46684709

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

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

67856827
<!-- ============================================================ -->
67866828
# Acknowledgements # {#acknowledgements}

0 commit comments

Comments
 (0)