Skip to content

Commit 476502e

Browse files
Sketch out IDBCursor.close()
1 parent 6f17004 commit 476502e

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
@@ -4395,6 +4395,7 @@ interface IDBCursor {
43954395
void advance([EnforceRange] unsigned long count);
43964396
void continue(optional any key);
43974397
void continuePrimaryKey(any key, any primaryKey);
4398+
void close();
43984399

43994400
[NewObject] IDBRequest update(any value);
44004401
[NewObject] IDBRequest delete();
@@ -4438,7 +4439,8 @@ enum IDBCursorDirection {
44384439
The <dfn attribute for=IDBCursor>source</dfn> attribute's getter must
44394440
return the [=cursor/source=] of the [=cursor=]. This
44404441
attribute never returns null or throws an exception, even if the
4441-
cursor is currently being iterated, has iterated past its end, or its
4442+
cursor is currently being iterated, has iterated past its end,
4443+
{{IDBCursor/close()}} has been called, or its
44424444
[=/transaction=] is not [=transaction/active=].
44434445

44444446
The <dfn attribute for=IDBCursor>direction</dfn> attribute's getter
@@ -4508,6 +4510,10 @@ return the [=cursor/request=] of the [=cursor=].
45084510
Advances the cursor to the next [=object-store/record=] in range matching
45094511
or after |key| and |primaryKey|. Throws an "{{InvalidAccessError}}" {{DOMException}}
45104512
if the [=cursor/source=] is not an [=/index=].
4513+
4514+
: |cursor| . {{IDBCursor/close()|close}}()
4515+
::
4516+
Signals that the cursor is no longer needed, and that any associated resources can be released.
45114517
</dl>
45124518
</div>
45134519

@@ -4529,9 +4535,9 @@ invoked, must run these steps:
45294535
1. If the cursor's [=cursor/source=] or [=effective object
45304536
store=] has been deleted, [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
45314537

4532-
1. If this cursor's [=cursor/got value flag=] is false, indicating that
4533-
the cursor is being iterated or has iterated past its end,
4534-
[=throw=] an "{{InvalidStateError}}" {{DOMException}}.
4538+
1. If this cursor's [=cursor/got value flag=] is false
4539+
(indicating that the cursor is being iterated, has iterated past its end, or that {{IDBCursor/close()}} was called),
4540+
then [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
45354541

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

@@ -4572,9 +4578,9 @@ invoked, must run these steps:
45724578
[=effective object store=] has been deleted, [=throw=] an
45734579
"{{InvalidStateError}}" {{DOMException}}.
45744580

4575-
1. If this cursor's [=cursor/got value flag=] is false, indicating that
4576-
the cursor is being iterated or has iterated past its end,
4577-
[=throw=] an "{{InvalidStateError}}" {{DOMException}}.
4581+
1. If this cursor'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}}.
45784584

45794585
1. If |key| is given, then:
45804586

@@ -4638,9 +4644,9 @@ The <dfn method for=IDBCursor>continuePrimaryKey(|key|,
46384644
1. If this cursor's [=cursor/direction=] is not {{"next"}} or {{"prev"}},
46394645
[=throw=] an "{{InvalidAccessError}}" {{DOMException}}.
46404646

4641-
1. If this cursor's [=cursor/got value flag=] is false, indicating that
4642-
the cursor is being iterated or has iterated past its end,
4643-
[=throw=] an "{{InvalidStateError}}" {{DOMException}}.
4647+
1. If this cursor'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}}.
46444650

46454651
1. Let |r| be the result of running [=convert a value to
46464652
a key=] with |key|. Rethrow any exceptions.
@@ -4699,6 +4705,40 @@ The <dfn method for=IDBCursor>continuePrimaryKey(|key|,
46994705
flag=] has been set to false.
47004706
</aside>
47014707

4708+
<div class=algorithm>
4709+
4710+
The <dfn method for=IDBCursor>close()</dfn> method, when invoked, must run these steps:
4711+
4712+
1. Let |transaction| be this [=cursor=]'s
4713+
[=cursor/transaction=].
4714+
4715+
1. If |transaction|'s [=transaction/state=] is not [=transaction/active=], then [=throw=] a "{{TransactionInactiveError}}" {{DOMException}}.
4716+
4717+
1. If this [=cursor=]'s [=cursor/source=] or [=effective object store=] has been deleted, [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
4718+
4719+
1. If this [=cursor=]'s [=cursor/got value flag=] is false
4720+
(indicating that the cursor is being iterated, has iterated past its end, or that {{IDBCursor/close()}} was called),
4721+
then [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
4722+
4723+
1. Set this [=cursor=]'s [=cursor/got value flag=] to false.
4724+
4725+
1. Set this [=cursor=]'s [=cursor/key=] to undefined.
4726+
4727+
1. If this [=cursor=]'s [=cursor/source=] is an [=/index=], then set this [=cursor=]'s [=object store position=] to undefined.
4728+
4729+
1. If this [=cursor=]'s [=cursor/key only flag=] is false, then set this [=cursor=]'s [=cursor/value=] to undefined.
4730+
4731+
</div>
4732+
4733+
<aside class=note>
4734+
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.
4735+
</aside>
4736+
4737+
<aside class=advisement>
4738+
&#x1F6A7;
4739+
The {{IDBCursor/close()}} method is new in this edition.
4740+
&#x1F6A7;
4741+
</aside>
47024742

47034743

47044744
<div class=note>
@@ -4746,9 +4786,9 @@ invoked, must run these steps:
47464786
1. If the cursor's [=cursor/source=] or [=effective object
47474787
store=] has been deleted, [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
47484788

4749-
1. If this cursor's [=cursor/got value flag=] is false, indicating that
4750-
the cursor is being iterated or has iterated past its end,
4751-
[=throw=] an "{{InvalidStateError}}" {{DOMException}}.
4789+
1. If this cursor's [=cursor/got value flag=] is false
4790+
(indicating that the cursor is being iterated, has iterated past its end, or that {{IDBCursor/close()}} was called),
4791+
then [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
47524792

47534793
1. If this cursor's [=cursor/key only flag=] is true, [=throw=] an
47544794
"{{InvalidStateError}}" {{DOMException}}.
@@ -4813,9 +4853,9 @@ must run these steps:
48134853
1. If the cursor's [=cursor/source=] or [=effective object
48144854
store=] has been deleted, [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
48154855

4816-
1. If this cursor's [=cursor/got value flag=] is false, indicating that
4817-
the cursor is being iterated or has iterated past its end,
4818-
[=throw=] an "{{InvalidStateError}}" {{DOMException}}.
4856+
1. If this cursor's [=cursor/got value flag=] is false
4857+
(indicating that the cursor is being iterated, has iterated past its end, or that {{IDBCursor/close()}} was called),
4858+
then [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
48194859

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

68976938
<!-- ============================================================ -->
68986939
# Acknowledgements # {#acknowledgements}

0 commit comments

Comments
 (0)