Skip to content

Commit 4bc6a59

Browse files
Sketch out IDBCursor.close()
1 parent d1256fe commit 4bc6a59

File tree

1 file changed

+58
-16
lines changed

1 file changed

+58
-16
lines changed

index.bs

Lines changed: 58 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4299,6 +4299,7 @@ interface IDBCursor {
42994299
void advance([EnforceRange] unsigned long count);
43004300
void continue(optional any key);
43014301
void continuePrimaryKey(any key, any primaryKey);
4302+
void close();
43024303

43034304
[NewObject] IDBRequest update(any value);
43044305
[NewObject] IDBRequest delete();
@@ -4342,7 +4343,8 @@ enum IDBCursorDirection {
43424343
The <dfn attribute for=IDBCursor>source</dfn> attribute's getter must
43434344
return [=/this=]'s [=cursor/source=]. This
43444345
attribute never returns null or throws an exception, even if the
4345-
cursor is currently being iterated, has iterated past its end, or its
4346+
cursor is currently being iterated, has iterated past its end,
4347+
{{IDBCursor/close()}} has been called, or its
43464348
[=/transaction=] is not [=transaction/active=].
43474349

43484350
The <dfn attribute for=IDBCursor>direction</dfn> attribute's getter
@@ -4412,6 +4414,12 @@ return [=/this=]'s [=cursor/request=].
44124414
Advances the cursor to the next [=object-store/record=] in range matching
44134415
or after |key| and |primaryKey|. Throws an "{{InvalidAccessError}}" {{DOMException}}
44144416
if the [=cursor/source=] is not an [=/index=].
4417+
4418+
4419+
: |cursor| . {{IDBCursor/close()|close}}()
4420+
::
4421+
Signals that the cursor is no longer needed, and that any associated resources can be released.
4422+
44154423
</div>
44164424

44174425

@@ -4431,9 +4439,9 @@ invoked, must run these steps:
44314439
1. If [=/this=]'s [=cursor/source=] or [=effective object
44324440
store=] has been deleted, [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
44334441

4434-
1. If [=/this=]'s [=cursor/got value flag=] is false, indicating that
4435-
the cursor is being iterated or has iterated past its end,
4436-
[=throw=] an "{{InvalidStateError}}" {{DOMException}}.
4442+
1. If [=/this=]'s [=cursor/got value flag=] is false
4443+
(indicating that the cursor is being iterated, has iterated past its end, or that {{IDBCursor/close()}} was called),
4444+
then [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
44374445

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

@@ -4473,9 +4481,9 @@ invoked, must run these steps:
44734481
[=effective object store=] has been deleted, [=throw=] an
44744482
"{{InvalidStateError}}" {{DOMException}}.
44754483

4476-
1. If [=/this=]'s [=cursor/got value flag=] is false, indicating that
4477-
the cursor is being iterated or has iterated past its end,
4478-
[=throw=] an "{{InvalidStateError}}" {{DOMException}}.
4484+
1. If [=/this=]'s [=cursor/got value flag=] is false
4485+
(indicating that the cursor is being iterated, has iterated past its end, or that {{IDBCursor/close()}} was called),
4486+
then [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
44794487

44804488
1. If |key| is given, then:
44814489

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

4541-
1. If [=/this=]'s [=cursor/got value flag=] is false, indicating that
4542-
the cursor is being iterated or has iterated past its end,
4543-
[=throw=] an "{{InvalidStateError}}" {{DOMException}}.
4549+
1. If [=/this=]'s [=cursor/got value flag=] is false
4550+
(indicating that the cursor is being iterated, has iterated past its end, or that {{IDBCursor/close()}} was called),
4551+
then [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
45444552

45454553
1. Let |r| be the result of running [=convert a value to
45464554
a key=] with |key|. Rethrow any exceptions.
@@ -4599,6 +4607,39 @@ The <dfn method for=IDBCursor>continuePrimaryKey(|key|,
45994607
flag=] has been set to false.
46004608
</aside>
46014609

4610+
<div class=algorithm>
4611+
4612+
The <dfn method for=IDBCursor>close()</dfn> method, when invoked, must run these steps:
4613+
4614+
1. Let |transaction| be [=/this=]'s [=cursor/transaction=].
4615+
4616+
1. If |transaction|'s [=transaction/state=] is not [=transaction/active=], then [=throw=] a "{{TransactionInactiveError}}" {{DOMException}}.
4617+
4618+
1. If [=/this=]'s [=cursor/source=] or [=effective object store=] has been deleted, then [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
4619+
4620+
1. If [=/this=]'s [=cursor/got value flag=] is false
4621+
(indicating that the cursor is being iterated, has iterated past its end, or that {{IDBCursor/close()}} was called),
4622+
then [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
4623+
4624+
1. Set [=/this=]'s [=cursor/got value flag=] to false.
4625+
4626+
1. Set [=/this=]'s [=cursor/key=] to undefined.
4627+
4628+
1. If [=/this=]'s [=cursor/source=] is an [=/index=], then set [=/this=]'s [=object store position=] to undefined.
4629+
4630+
1. If [=/this=]'s [=cursor/key only flag=] is false, then set [=/this=]'s [=cursor/value=] to undefined.
4631+
4632+
</div>
4633+
4634+
<aside class=note>
4635+
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.
4636+
</aside>
4637+
4638+
<aside class=advisement>
4639+
&#x1F6A7;
4640+
The {{IDBCursor/close()}} method is new in this edition.
4641+
&#x1F6A7;
4642+
</aside>
46024643

46034644

46044645
<div class="domintro note">
@@ -4643,9 +4684,9 @@ invoked, must run these steps:
46434684
1. If [=/this=]'s [=cursor/source=] or [=effective object
46444685
store=] has been deleted, [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
46454686

4646-
1. If [=/this=]'s [=cursor/got value flag=] is false, indicating that
4647-
the cursor is being iterated or has iterated past its end,
4648-
[=throw=] an "{{InvalidStateError}}" {{DOMException}}.
4687+
1. If [=/this=]'s [=cursor/got value flag=] is false
4688+
(indicating that the cursor is being iterated, has iterated past its end, or that {{IDBCursor/close()}} was called),
4689+
then [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
46494690

46504691
1. If [=/this=]'s [=cursor/key only flag=] is true, [=throw=] an
46514692
"{{InvalidStateError}}" {{DOMException}}.
@@ -4709,9 +4750,9 @@ must run these steps:
47094750
1. If [=/this=]'s [=cursor/source=] or [=effective object
47104751
store=] has been deleted, [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
47114752

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

47164757
1. If [=/this=]'s [=cursor/key only flag=] is true, [=throw=] an
47174758
"{{InvalidStateError}}" {{DOMException}}.
@@ -6816,6 +6857,7 @@ For the revision history of the second edition, see [that document's Revision Hi
68166857
* Transactions are now temporarily made inactive during clone operations.
68176858
* Added {{IDBTransactionOptions/durability}} option and {{IDBTransaction/durability}} attribute. ([Issue #50](https://github.com/w3c/IndexedDB/issues/50))
68186859
* Specified [[#transaction-scheduling]] more precisely and disallow starting read/write transactions while read-only transactions with overlapping scope are running. ([Issue #253](https://github.com/w3c/IndexedDB/issues/253))
6860+
* Added {{IDBCursor/close()}} method for {{IDBCursor}}. ([Issue #185](https://github.com/w3c/IndexedDB/issues/185))
68196861

68206862
<!-- ============================================================ -->
68216863
# Acknowledgements # {#acknowledgements}

0 commit comments

Comments
 (0)