Skip to content

Commit 33dde6f

Browse files
Sketch out IDBCursor.close()
1 parent 29d45f4 commit 33dde6f

File tree

1 file changed

+57
-16
lines changed

1 file changed

+57
-16
lines changed

index.bs

Lines changed: 57 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,40 @@ 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 [=cursor=]'s
4639+
[=cursor/transaction=].
4640+
4641+
1. If |transaction|'s [=transaction/state=] is not [=transaction/active=], then [=throw=] a "{{TransactionInactiveError}}" {{DOMException}}.
4642+
4643+
1. If this [=cursor=]'s [=cursor/source=] or [=effective object store=] has been deleted, [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
4644+
4645+
1. If this [=cursor=]'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 [=cursor=]'s [=cursor/got value flag=] to false.
4650+
4651+
1. Set this [=cursor=]'s [=cursor/key=] to undefined.
4652+
4653+
1. If this [=cursor=]'s [=cursor/source=] is an [=/index=], then set this [=cursor=]'s [=object store position=] to undefined.
4654+
4655+
1. If this [=cursor=]'s [=cursor/key only flag=] is false, then set this [=cursor=]'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>
46284668

46294669

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

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}}.
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}}.
46774717

46784718
1. If **this**'s [=cursor/key only flag=] is true, [=throw=] an
46794719
"{{InvalidStateError}}" {{DOMException}}.
@@ -4737,9 +4777,9 @@ must run these steps:
47374777
1. If **this**'s [=cursor/source=] or [=effective object
47384778
store=] has been deleted, [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
47394779

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}}.
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}}.
47434783

47444784
1. If **this**'s [=cursor/key only flag=] is true, [=throw=] an
47454785
"{{InvalidStateError}}" {{DOMException}}.
@@ -6814,6 +6854,7 @@ For the revision history of the second edition, see [that document's Revision Hi
68146854
* Added {{IDBCursor/request}} attribute. ([Issue #255](https://github.com/w3c/IndexedDB/issues/255))
68156855
* Removed handling for nonstandard `lastModifiedDate` property of {{File}} objects. ([Issue #215](https://github.com/w3c/IndexedDB/issues/215))
68166856
* 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))
68176858

68186859
<!-- ============================================================ -->
68196860
# Acknowledgements # {#acknowledgements}

0 commit comments

Comments
 (0)