Skip to content

Commit 80732ac

Browse files
Sketch out IDBCursor.close()
1 parent 98099f2 commit 80732ac

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

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

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

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

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

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

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

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

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

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

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

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

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

46304669

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

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

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

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

47454784
1. If **this**'s [=cursor/key only flag=] is true, [=throw=] an
47464785
"{{InvalidStateError}}" {{DOMException}}.
@@ -6815,6 +6854,7 @@ For the revision history of the second edition, see [that document's Revision Hi
68156854
* Added {{IDBCursor/request}} attribute. ([Issue #255](https://github.com/w3c/IndexedDB/issues/255))
68166855
* Removed handling for nonstandard `lastModifiedDate` property of {{File}} objects. ([Issue #215](https://github.com/w3c/IndexedDB/issues/215))
68176856
* Remove escaping {{IDBKeyRange/includes()}} method. ([Issue #294](https://github.com/w3c/IndexedDB/issues/294))
6857+
* Added {{IDBCursor/close()}} method for {{IDBCursor}}. ([Issue #185](https://github.com/w3c/IndexedDB/issues/185))
68186858

68196859
<!-- ============================================================ -->
68206860
# Acknowledgements # {#acknowledgements}

0 commit comments

Comments
 (0)