Skip to content

Commit bb0c505

Browse files
Sketch out IDBCursor.close()
1 parent 95d8712 commit bb0c505

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
@@ -4324,6 +4324,7 @@ interface IDBCursor {
43244324
void advance([EnforceRange] unsigned long count);
43254325
void continue(optional any key);
43264326
void continuePrimaryKey(any key, any primaryKey);
4327+
void close();
43274328

43284329
[NewObject] IDBRequest update(any value);
43294330
[NewObject] IDBRequest delete();
@@ -4367,7 +4368,8 @@ enum IDBCursorDirection {
43674368
The <dfn attribute for=IDBCursor>source</dfn> attribute's getter must
43684369
return **this**'s [=cursor/source=]. This
43694370
attribute never returns null or throws an exception, even if the
4370-
cursor is currently being iterated, has iterated past its end, or its
4371+
cursor is currently being iterated, has iterated past its end,
4372+
{{IDBCursor/close()}} has been called, or its
43714373
[=/transaction=] is not [=transaction/active=].
43724374

43734375
The <dfn attribute for=IDBCursor>direction</dfn> attribute's getter
@@ -4437,6 +4439,10 @@ return **this**'s [=cursor/request=].
44374439
Advances the cursor to the next [=object-store/record=] in range matching
44384440
or after |key| and |primaryKey|. Throws an "{{InvalidAccessError}}" {{DOMException}}
44394441
if the [=cursor/source=] is not an [=/index=].
4442+
4443+
: |cursor| . {{IDBCursor/close()|close}}()
4444+
::
4445+
Signals that the cursor is no longer needed, and that any associated resources can be released.
44404446
</dl>
44414447
</div>
44424448

@@ -4457,9 +4463,9 @@ invoked, must run these steps:
44574463
1. If **this**'s [=cursor/source=] or [=effective object
44584464
store=] has been deleted, [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
44594465

4460-
1. If **this**'s [=cursor/got value flag=] is false, indicating that
4461-
the cursor is being iterated or has iterated past its end,
4462-
[=throw=] an "{{InvalidStateError}}" {{DOMException}}.
4466+
1. If **this**'s [=cursor/got value flag=] is false
4467+
(indicating that the cursor is being iterated, has iterated past its end, or that {{IDBCursor/close()}} was called),
4468+
then [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
44634469

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

@@ -4499,9 +4505,9 @@ invoked, must run these steps:
44994505
[=effective object store=] has been deleted, [=throw=] an
45004506
"{{InvalidStateError}}" {{DOMException}}.
45014507

4502-
1. If **this**'s [=cursor/got value flag=] is false, indicating that
4503-
the cursor is being iterated or has iterated past its end,
4504-
[=throw=] an "{{InvalidStateError}}" {{DOMException}}.
4508+
1. If **this**'s [=cursor/got value flag=] is false
4509+
(indicating that the cursor is being iterated, has iterated past its end, or that {{IDBCursor/close()}} was called),
4510+
then [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
45054511

45064512
1. If |key| is given, then:
45074513

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

4567-
1. If **this**'s [=cursor/got value flag=] is false, indicating that
4568-
the cursor is being iterated or has iterated past its end,
4569-
[=throw=] an "{{InvalidStateError}}" {{DOMException}}.
4573+
1. If **this**'s [=cursor/got value flag=] is false
4574+
(indicating that the cursor is being iterated, has iterated past its end, or that {{IDBCursor/close()}} was called),
4575+
then [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
45704576

45714577
1. Let |r| be the result of running [=convert a value to
45724578
a key=] with |key|. Rethrow any exceptions.
@@ -4625,6 +4631,39 @@ The <dfn method for=IDBCursor>continuePrimaryKey(|key|,
46254631
flag=] has been set to false.
46264632
</aside>
46274633

4634+
<div class=algorithm>
4635+
4636+
The <dfn method for=IDBCursor>close()</dfn> method, when invoked, must run these steps:
4637+
4638+
1. Let |transaction| be **this**'s [=cursor/transaction=].
4639+
4640+
1. If |transaction|'s [=transaction/state=] is not [=transaction/active=], then [=throw=] a "{{TransactionInactiveError}}" {{DOMException}}.
4641+
4642+
1. If **this**'s [=cursor/source=] or [=effective object store=] has been deleted, then [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
4643+
4644+
1. If **this**'s [=cursor/got value flag=] is false
4645+
(indicating that the cursor is being iterated, has iterated past its end, or that {{IDBCursor/close()}} was called),
4646+
then [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
4647+
4648+
1. Set **this**'s [=cursor/got value flag=] to false.
4649+
4650+
1. Set **this**'s [=cursor/key=] to undefined.
4651+
4652+
1. If **this**'s [=cursor/source=] is an [=/index=], then set **this**'s [=object store position=] to undefined.
4653+
4654+
1. If **this**'s [=cursor/key only flag=] is false, then set **this**'s [=cursor/value=] to undefined.
4655+
4656+
</div>
4657+
4658+
<aside class=note>
4659+
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.
4660+
</aside>
4661+
4662+
<aside class=advisement>
4663+
&#x1F6A7;
4664+
The {{IDBCursor/close()}} method is new in this edition.
4665+
&#x1F6A7;
4666+
</aside>
46284667

46294668

46304669
<div class=note>
@@ -4671,9 +4710,9 @@ invoked, must run these steps:
46714710
1. If **this**'s [=cursor/source=] or [=effective object
46724711
store=] has been deleted, [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
46734712

4674-
1. If **this**'s [=cursor/got value flag=] is false, indicating that
4675-
the cursor is being iterated or has iterated past its end,
4676-
[=throw=] an "{{InvalidStateError}}" {{DOMException}}.
4713+
1. If **this**'s [=cursor/got value flag=] is false
4714+
(indicating that the cursor is being iterated, has iterated past its end, or that {{IDBCursor/close()}} was called),
4715+
then [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
46774716

46784717
1. If **this**'s [=cursor/key only flag=] is true, [=throw=] an
46794718
"{{InvalidStateError}}" {{DOMException}}.
@@ -4737,9 +4776,9 @@ must run these steps:
47374776
1. If **this**'s [=cursor/source=] or [=effective object
47384777
store=] has been deleted, [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
47394778

4740-
1. If **this**'s [=cursor/got value flag=] is false, indicating that
4741-
the cursor is being iterated or has iterated past its end,
4742-
[=throw=] an "{{InvalidStateError}}" {{DOMException}}.
4779+
1. If **this**'s [=cursor/got value flag=] is false
4780+
(indicating that the cursor is being iterated, has iterated past its end, or that {{IDBCursor/close()}} was called),
4781+
then [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
47434782

47444783
1. If **this**'s [=cursor/key only flag=] is true, [=throw=] an
47454784
"{{InvalidStateError}}" {{DOMException}}.
@@ -6824,6 +6863,7 @@ For the revision history of the second edition, see [that document's Revision Hi
68246863
* Remove escaping {{IDBKeyRange/includes()}} method. ([Issue #294](https://github.com/w3c/IndexedDB/issues/294))
68256864
* Restrict array keys to [=/Array exotic objects=] (i.e. disallow proxies). ([Issue #309](https://github.com/w3c/IndexedDB/issues/309])
68266865
* Transactions are now temporarily made inactive during clone operations.
6866+
* Added {{IDBCursor/close()}} method for {{IDBCursor}}. ([Issue #185](https://github.com/w3c/IndexedDB/issues/185))
68276867

68286868
<!-- ============================================================ -->
68296869
# Acknowledgements # {#acknowledgements}

0 commit comments

Comments
 (0)