From 8222e84a4136111a1dfe4d28cd32c6013bebbeb5 Mon Sep 17 00:00:00 2001 From: Joshua Bell Date: Thu, 21 May 2020 12:04:48 -0700 Subject: [PATCH] git squash commit for cursor-close. 442fb99b8d0b6cf24c2a120b2b3f02d15bed6a69 Sketch out IDBCursor.close() 343d7dd16048cb0fdaa04605c76ebb42ae51e929 rebased and updated --- index.bs | 74 ++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 58 insertions(+), 16 deletions(-) diff --git a/index.bs b/index.bs index 0f475ef..1e7e46a 100644 --- a/index.bs +++ b/index.bs @@ -4261,6 +4261,7 @@ interface IDBCursor { undefined advance([EnforceRange] unsigned long count); undefined continue(optional any key); undefined continuePrimaryKey(any key, any primaryKey); + undefined close(); [NewObject] IDBRequest update(any value); [NewObject] IDBRequest delete(); @@ -4306,7 +4307,8 @@ return [=/this=]'s [=cursor/source=]. @@ -4383,6 +4385,12 @@ return [=/this=]'s [=cursor/request=]. Advances the cursor to the next [=object-store/record=] in range matching or after |key| and |primaryKey|. Throws an "{{InvalidAccessError}}" {{DOMException}} if the [=cursor/source=] is not an [=/index=]. + + + : |cursor| . {{IDBCursor/close()|close}}() + :: + Signals that the cursor is no longer needed, and that any associated resources can be released. + @@ -4401,9 +4409,9 @@ The advance(|count|) method steps are: 1. If [=/this=]'s [=cursor/source=] or [=cursor/effective object store=] has been deleted, [=exception/throw=] an "{{InvalidStateError}}" {{DOMException}}. -1. If [=/this=]'s [=cursor/got value flag=] is false, indicating that - the cursor is being iterated or has iterated past its end, - [=exception/throw=] an "{{InvalidStateError}}" {{DOMException}}. +1. If [=/this=]'s [=cursor/got value flag=] is false + (indicating that the cursor is being iterated, has iterated past its end, or that {{IDBCursor/close()}} was called), + then [=exception/throw=] an "{{InvalidStateError}}" {{DOMException}}. 1. Set [=/this=]'s [=cursor/got value flag=] to false. @@ -4441,9 +4449,9 @@ The continue(|key|) method steps are: [=cursor/effective object store=] has been deleted, [=exception/throw=] an "{{InvalidStateError}}" {{DOMException}}. -1. If [=/this=]'s [=cursor/got value flag=] is false, indicating that - the cursor is being iterated or has iterated past its end, - [=exception/throw=] an "{{InvalidStateError}}" {{DOMException}}. +1. If [=/this=]'s [=cursor/got value flag=] is false + (indicating that the cursor is being iterated, has iterated past its end, or that {{IDBCursor/close()}} was called), + then [=exception/throw=] an "{{InvalidStateError}}" {{DOMException}}. 1. If |key| is given, then: @@ -4503,9 +4511,9 @@ The continuePrimaryKey(|key|, |primaryKey|) meth 1. If [=/this=]'s [=cursor/direction=] is not "{{IDBCursorDirection/next}}" or "{{IDBCursorDirection/prev}}", [=exception/throw=] an "{{InvalidAccessError}}" {{DOMException}}. -1. If [=/this=]'s [=cursor/got value flag=] is false, indicating that - the cursor is being iterated or has iterated past its end, - [=exception/throw=] an "{{InvalidStateError}}" {{DOMException}}. +1. If [=/this=]'s [=cursor/got value flag=] is false + (indicating that the cursor is being iterated, has iterated past its end, or that {{IDBCursor/close()}} was called), + then [=exception/throw=] an "{{InvalidStateError}}" {{DOMException}}. 1. Let |r| be the result of [=/converting a value to a key=] with |key|. Rethrow any exceptions. @@ -4562,6 +4570,39 @@ The continuePrimaryKey(|key|, |primaryKey|) meth flag=] has been set to false. +
+ +The close() method steps are: + +1. Let |transaction| be [=/this=]'s [=cursor/transaction=]. + +1. If |transaction|'s [=transaction/state=] is not [=transaction/active=], then [=exception/throw=] a "{{TransactionInactiveError}}" {{DOMException}}. + +1. If [=/this=]'s [=cursor/source=] or [=cursor/effective object store=] has been deleted, then [=exception/throw=] an "{{InvalidStateError}}" {{DOMException}}. + +1. If [=/this=]'s [=cursor/got value flag=] is false + (indicating that the cursor is being iterated, has iterated past its end, or that {{IDBCursor/close()}} was called), + then [=exception/throw=] an "{{InvalidStateError}}" {{DOMException}}. + +1. Set [=/this=]'s [=cursor/got value flag=] to false. + +1. Set [=/this=]'s [=cursor/key=] to undefined. + +1. If [=/this=]'s [=cursor/source=] is an [=/index=], then set [=/this=]'s [=cursor/object store position=] to undefined. + +1. If [=/this=]'s [=cursor/key only flag=] is false, then set [=/this=]'s [=cursor/value=] to undefined. + +
+ + + +
@@ -4605,9 +4646,9 @@ The update(|value|) method steps are: 1. If [=/this=]'s [=cursor/source=] or [=cursor/effective object store=] has been deleted, [=exception/throw=] an "{{InvalidStateError}}" {{DOMException}}. -1. If [=/this=]'s [=cursor/got value flag=] is false, indicating that - the cursor is being iterated or has iterated past its end, - [=exception/throw=] an "{{InvalidStateError}}" {{DOMException}}. +1. If [=/this=]'s [=cursor/got value flag=] is false + (indicating that the cursor is being iterated, has iterated past its end, or that {{IDBCursor/close()}} was called), + then [=exception/throw=] an "{{InvalidStateError}}" {{DOMException}}. 1. If [=/this=]'s [=cursor/key only flag=] is true, [=exception/throw=] an "{{InvalidStateError}}" {{DOMException}}. @@ -4666,9 +4707,9 @@ The delete() method steps are: 1. If [=/this=]'s [=cursor/source=] or [=cursor/effective object store=] has been deleted, [=exception/throw=] an "{{InvalidStateError}}" {{DOMException}}. -1. If [=/this=]'s [=cursor/got value flag=] is false, indicating that - the cursor is being iterated or has iterated past its end, - [=exception/throw=] an "{{InvalidStateError}}" {{DOMException}}. +1. If [=/this=]'s [=cursor/got value flag=] is false + (indicating that the cursor is being iterated, has iterated past its end, or that {{IDBCursor/close()}} was called), + then [=exception/throw=] an "{{InvalidStateError}}" {{DOMException}}. 1. If [=/this=]'s [=cursor/key only flag=] is true, [=exception/throw=] an "{{InvalidStateError}}" {{DOMException}}. @@ -6781,6 +6822,7 @@ For the revision history of the second edition, see [that document's Revision Hi * 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)) * Added Accessibility considerations section. ([Issue #327](https://github.com/w3c/IndexedDB/issues/327)) * Used [[infra]]'s list sorting definition. ([Issue #346](https://github.com/w3c/IndexedDB/issues/346)) +* Added {{IDBCursor/close()}} method for {{IDBCursor}}. ([Issue #185](https://github.com/w3c/IndexedDB/issues/185)) # Acknowledgements # {#acknowledgements}