Skip to content

Commit d261a89

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

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
@@ -4259,6 +4259,7 @@ interface IDBCursor {
42594259
void advance([EnforceRange] unsigned long count);
42604260
void continue(optional any key);
42614261
void continuePrimaryKey(any key, any primaryKey);
4262+
void close();
42624263

42634264
[NewObject] IDBRequest update(any value);
42644265
[NewObject] IDBRequest delete();
@@ -4304,7 +4305,8 @@ return [=/this=]'s [=cursor/source=].
43044305

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

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

43864394

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

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

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

@@ -4439,9 +4447,9 @@ The <dfn method for=IDBCursor>continue(|key|)</dfn> method steps are:
44394447
[=effective object store=] has been deleted, [=throw=] an
44404448
"{{InvalidStateError}}" {{DOMException}}.
44414449

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

44464454
1. If |key| is given, then:
44474455

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

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

45084516
1. Let |r| be the result of running [=convert a value to
45094517
a key=] with |key|. Rethrow any exceptions.
@@ -4560,6 +4568,39 @@ The <dfn method for=IDBCursor>continuePrimaryKey(|key|, |primaryKey|)</dfn> meth
45604568
flag=] has been set to false.
45614569
</aside>
45624570

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

45644605

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

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

46104651
1. If [=/this=]'s [=cursor/key only flag=] is true, [=throw=] an
46114652
"{{InvalidStateError}}" {{DOMException}}.
@@ -4664,9 +4705,9 @@ The <dfn method for=IDBCursor>delete()</dfn> method steps are:
46644705
1. If [=/this=]'s [=cursor/source=] or [=effective object
46654706
store=] has been deleted, [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
46664707

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

46714712
1. If [=/this=]'s [=cursor/key only flag=] is true, [=throw=] an
46724713
"{{InvalidStateError}}" {{DOMException}}.
@@ -6759,6 +6800,7 @@ For the revision history of the second edition, see [that document's Revision Hi
67596800
* Transactions are now temporarily made inactive during clone operations.
67606801
* Added {{IDBTransactionOptions/durability}} option and {{IDBTransaction/durability}} attribute. ([Issue #50](https://github.com/w3c/IndexedDB/issues/50))
67616802
* 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))
6803+
* Added {{IDBCursor/close()}} method for {{IDBCursor}}. ([Issue #185](https://github.com/w3c/IndexedDB/issues/185))
67626804

67636805
<!-- ============================================================ -->
67646806
# Acknowledgements # {#acknowledgements}

0 commit comments

Comments
 (0)