Skip to content

Commit 38a5216

Browse files
Sketch out IDBCursor.close()
1 parent 093afa4 commit 38a5216

File tree

1 file changed

+56
-16
lines changed

1 file changed

+56
-16
lines changed

index.bs

Lines changed: 56 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4344,6 +4344,7 @@ interface IDBCursor {
43444344
void advance([EnforceRange] unsigned long count);
43454345
void continue(optional any key);
43464346
void continuePrimaryKey(any key, any primaryKey);
4347+
void close();
43474348

43484349
[NewObject] IDBRequest update(any value);
43494350
[NewObject] IDBRequest delete();
@@ -4387,7 +4388,8 @@ enum IDBCursorDirection {
43874388
The <dfn attribute for=IDBCursor>source</dfn> attribute's getter must
43884389
return **this**'s [=cursor/source=]. This
43894390
attribute never returns null or throws an exception, even if the
4390-
cursor is currently being iterated, has iterated past its end, or its
4391+
cursor is currently being iterated, has iterated past its end,
4392+
{{IDBCursor/close()}} has been called, or its
43914393
[=/transaction=] is not [=transaction/active=].
43924394

43934395
The <dfn attribute for=IDBCursor>direction</dfn> attribute's getter
@@ -4458,6 +4460,10 @@ return **this**'s [=cursor/request=].
44584460
Advances the cursor to the next [=object-store/record=] in range matching
44594461
or after |key| and |primaryKey|. Throws an "{{InvalidAccessError}}" {{DOMException}}
44604462
if the [=cursor/source=] is not an [=/index=].
4463+
4464+
: |cursor| . {{IDBCursor/close()|close}}()
4465+
::
4466+
Signals that the cursor is no longer needed, and that any associated resources can be released.
44614467
</dl>
44624468
</div>
44634469

@@ -4478,9 +4484,9 @@ invoked, must run these steps:
44784484
1. If **this**'s [=cursor/source=] or [=effective object
44794485
store=] has been deleted, [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
44804486

4481-
1. If **this**'s [=cursor/got value flag=] is false, indicating that
4482-
the cursor is being iterated or has iterated past its end,
4483-
[=throw=] an "{{InvalidStateError}}" {{DOMException}}.
4487+
1. If **this**'s [=cursor/got value flag=] is false
4488+
(indicating that the cursor is being iterated, has iterated past its end, or that {{IDBCursor/close()}} was called),
4489+
then [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
44844490

44854491
1. Set **this**'s [=cursor/got value flag=] to false.
44864492

@@ -4520,9 +4526,9 @@ invoked, must run these steps:
45204526
[=effective object store=] has been deleted, [=throw=] an
45214527
"{{InvalidStateError}}" {{DOMException}}.
45224528

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

45274533
1. If |key| is given, then:
45284534

@@ -4585,9 +4591,9 @@ The <dfn method for=IDBCursor>continuePrimaryKey(|key|,
45854591
1. If **this**'s [=cursor/direction=] is not {{"next"}} or {{"prev"}},
45864592
[=throw=] an "{{InvalidAccessError}}" {{DOMException}}.
45874593

4588-
1. If **this**'s [=cursor/got value flag=] is false, indicating that
4589-
the cursor is being iterated or has iterated past its end,
4590-
[=throw=] an "{{InvalidStateError}}" {{DOMException}}.
4594+
1. If **this**'s [=cursor/got value flag=] is false
4595+
(indicating that the cursor is being iterated, has iterated past its end, or that {{IDBCursor/close()}} was called),
4596+
then [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
45914597

45924598
1. Let |r| be the result of running [=convert a value to
45934599
a key=] with |key|. Rethrow any exceptions.
@@ -4646,6 +4652,39 @@ The <dfn method for=IDBCursor>continuePrimaryKey(|key|,
46464652
flag=] has been set to false.
46474653
</aside>
46484654

4655+
<div class=algorithm>
4656+
4657+
The <dfn method for=IDBCursor>close()</dfn> method, when invoked, must run these steps:
4658+
4659+
1. Let |transaction| be **this**'s [=cursor/transaction=].
4660+
4661+
1. If |transaction|'s [=transaction/state=] is not [=transaction/active=], then [=throw=] a "{{TransactionInactiveError}}" {{DOMException}}.
4662+
4663+
1. If **this**'s [=cursor/source=] or [=effective object store=] has been deleted, then [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
4664+
4665+
1. If **this**'s [=cursor/got value flag=] is false
4666+
(indicating that the cursor is being iterated, has iterated past its end, or that {{IDBCursor/close()}} was called),
4667+
then [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
4668+
4669+
1. Set **this**'s [=cursor/got value flag=] to false.
4670+
4671+
1. Set **this**'s [=cursor/key=] to undefined.
4672+
4673+
1. If **this**'s [=cursor/source=] is an [=/index=], then set **this**'s [=object store position=] to undefined.
4674+
4675+
1. If **this**'s [=cursor/key only flag=] is false, then set **this**'s [=cursor/value=] to undefined.
4676+
4677+
</div>
4678+
4679+
<aside class=note>
4680+
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.
4681+
</aside>
4682+
4683+
<aside class=advisement>
4684+
&#x1F6A7;
4685+
The {{IDBCursor/close()}} method is new in this edition.
4686+
&#x1F6A7;
4687+
</aside>
46494688

46504689

46514690
<div class=note>
@@ -4692,9 +4731,9 @@ invoked, must run these steps:
46924731
1. If **this**'s [=cursor/source=] or [=effective object
46934732
store=] has been deleted, [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
46944733

4695-
1. If **this**'s [=cursor/got value flag=] is false, indicating that
4696-
the cursor is being iterated or has iterated past its end,
4697-
[=throw=] an "{{InvalidStateError}}" {{DOMException}}.
4734+
1. If **this**'s [=cursor/got value flag=] is false
4735+
(indicating that the cursor is being iterated, has iterated past its end, or that {{IDBCursor/close()}} was called),
4736+
then [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
46984737

46994738
1. If **this**'s [=cursor/key only flag=] is true, [=throw=] an
47004739
"{{InvalidStateError}}" {{DOMException}}.
@@ -4758,9 +4797,9 @@ must run these steps:
47584797
1. If **this**'s [=cursor/source=] or [=effective object
47594798
store=] has been deleted, [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
47604799

4761-
1. If **this**'s [=cursor/got value flag=] is false, indicating that
4762-
the cursor is being iterated or has iterated past its end,
4763-
[=throw=] an "{{InvalidStateError}}" {{DOMException}}.
4800+
1. If **this**'s [=cursor/got value flag=] is false
4801+
(indicating that the cursor is being iterated, has iterated past its end, or that {{IDBCursor/close()}} was called),
4802+
then [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
47644803

47654804
1. If **this**'s [=cursor/key only flag=] is true, [=throw=] an
47664805
"{{InvalidStateError}}" {{DOMException}}.
@@ -6864,6 +6903,7 @@ For the revision history of the second edition, see [that document's Revision Hi
68646903
* Restrict array keys to [=/Array exotic objects=] (i.e. disallow proxies). ([Issue #309](https://github.com/w3c/IndexedDB/issues/309))
68656904
* Transactions are now temporarily made inactive during clone operations.
68666905
* Added {{IDBTransactionOptions/durability}} option and {{IDBTransaction/durability}} attribute. ([Issue #50](https://github.com/w3c/IndexedDB/issues/50))
6906+
* Added {{IDBCursor/close()}} method for {{IDBCursor}}. ([Issue #185](https://github.com/w3c/IndexedDB/issues/185))
68676907

68686908
<!-- ============================================================ -->
68696909
# Acknowledgements # {#acknowledgements}

0 commit comments

Comments
 (0)