recursal/MDN huggingface dataset:
IDBCursor: continuePrimaryKey() method
======================================

 The **`continuePrimaryKey()`** method of the
 `IDBCursor` interface advances the cursor to the item whose key
 matches the key parameter as well as whose primary key matches the primary key
 parameter.

 A typical use case, is to resume the iteration where a previous cursor has been closed,
 without having to compare the keys one by one.

 Calling this method more than once before new cursor data has been loaded - for
 example, calling `continuePrimaryKey()` twice from the same onsuccess handler
 - results in an `InvalidStateError` being thrown on the second call because
 the cursor's got value flag has been unset.

 This method is only valid for cursors coming from an index. Using it for cursors coming
 from an object store will throw an error.

**Note:** This feature is available in Web Workers

Syntax
------


```js
continuePrimaryKey(key, primaryKey)
```

### Parameters

`key`

The key to position the cursor at.

`primaryKey`

The primary key to position the cursor at.

### Return value

None (`undefined`).

### Exceptions

This method may raise a `DOMException` of one of the following types:

`TransactionInactiveError` `DOMException`

Thrown if this IDBCursor's transaction is inactive.

`DataError` `DOMException`

Thrown if the key parameter has any of the following conditions:

* The key is not a valid key.
* The key is less than or equal to this cursor's position and the cursor's direction is `next` or `nextunique`.
* The key is greater than or equal to this cursor's position and this cursor's direction is `prev` or `prevunique`.

`InvalidStateError` `DOMException`

Thrown if the cursor is currently being iterated or has iterated past its end.

`InvalidAccessError` `DOMException`

Thrown if the cursor's direction is not `prev` or `next`.

Examples
--------

 here's how you can resume an iteration of all articles tagged with
 `"javascript"` since your last visit:


```js
let request = articleStore.index("tag").openCursor();
let count = 0;
let unreadList = [];
request.onsuccess = (event) => {
  let cursor = event.target.result;
  if (!cursor) {
    return;
  }
  let lastPrimaryKey = getLastIteratedArticleId();
  if (lastPrimaryKey > cursor.primaryKey) {
    cursor.continuePrimaryKey("javascript", lastPrimaryKey);
    return;
  }
  // update lastIteratedArticleId
  setLastIteratedArticleId(cursor.primaryKey);
  // preload 5 articles into the unread list;
  unreadList.push(cursor.value);
  if (++count < 5) {
    cursor.continue();
  }
};
```

Specifications
--------------

| Specification |
| --- |
| Indexed Database API 3.0 # ref-for-dom-idbcursor-continueprimarykey① |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* Using IndexedDB
* Starting transactions: `IDBDatabase`
* Using transactions: `IDBTransaction`
* Setting a range of keys: `IDBKeyRange`
* Retrieving and making changes to your data: `IDBObjectStore`
* Using cursors: `IDBCursor`
* Reference example: To-do Notifications (View the example live).
IDBCursor: request property
===========================

The **`request`** read-only property of the `IDBCursor` interface returns the `IDBRequest` used to obtain the cursor.

**Note:** This feature is available in Web Workers

Value
-----

An `IDBRequest` object instance.

Examples
--------

When you open a cursor, the `request` property is then available on that cursor object, to tell you what request object the cursor originated from. For example:


```js
function displayData() {
  list.textContent = "";
  const transaction = db.transaction(["rushAlbumList"], "readonly");
  const objectStore = transaction.objectStore("rushAlbumList");

  const request = objectStore.openCursor();

  request.onsuccess = (event) => {
    const cursor = event.target.result;
    if (cursor) {
      const listItem = document.createElement("li");
      listItem.textContent = `${cursor.value.albumTitle}, ${cursor.value.year}`;
      list.appendChild(listItem);
      console.log(cursor.request);
      cursor.continue();
    } else {
      console.log("Entries all displayed.");
    }
  };
}
```

Specifications
--------------

| Specification |
| --- |
| Indexed Database API 3.0 # ref-for-dom-idbcursor-request① |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* Using IndexedDB
* Starting transactions: `IDBDatabase`
* Using transactions: `IDBTransaction`
* Setting a range of keys: `IDBKeyRange`
* Retrieving and making changes to your data: `IDBObjectStore`
* Using cursors: `IDBCursor`
* Reference example: To-do Notifications (View the example live).
IDBCursor: source property
==========================

 The **`source`** read-only property of the
 `IDBCursor` interface returns the `IDBObjectStore` or
 `IDBIndex` that the cursor is iterating over. This function never returns
 null or throws an exception, even if the cursor is currently being iterated, has
 iterated past its end, or its transaction is not active.

**Note:** This feature is available in Web Workers

Value
-----

 The `IDBObjectStore` or `IDBIndex` that the cursor is
 iterating over.

Examples
--------

 In this simple fragment we create a transaction, retrieve an object store, then use a
 cursor to iterate through all the records in the object store. Within each iteration we
 log the source of the cursor, which will log our `IDBObjectStore` object to
 the console, something like this:


```json
IDBObjectStore {autoIncrement: false, transaction: IDBTransaction, indexNames: DOMStringList, keyPath: "albumTitle", name: "rushAlbumList"…}
```


 The cursor does not require us to select the data based
 on a key; we can just grab all of it. Also note that in each iteration of the loop,
 you can grab data from the current record under the cursor object using `cursor.value.foo`. For a complete working example, see our IDBCursor example (View the example live).


```js
function displayData() {
  const transaction = db.transaction(["rushAlbumList"], "readonly");
  const objectStore = transaction.objectStore("rushAlbumList");

  objectStore.openCursor().onsuccess = (event) => {
    const cursor = event.target.result;
    if (cursor) {
      const listItem = document.createElement("li");
      listItem.textContent = `${cursor.value.albumTitle}, ${cursor.value.year}`;
      list.appendChild(listItem);

      console.log(cursor.source);
      cursor.continue();
    } else {
      console.log("Entries all displayed.");
    }
  };
}
```

Specifications
--------------

| Specification |
| --- |
| Indexed Database API 3.0 # ref-for-dom-idbcursor-source① |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* Using IndexedDB
* Starting transactions: `IDBDatabase`
* Using transactions: `IDBTransaction`
* Setting a range of keys: `IDBKeyRange`
* Retrieving and making changes to your data: `IDBObjectStore`
* Using cursors: `IDBCursor`
* Reference example: To-do Notifications (View the example live).
IDBCursor: primaryKey property
==============================

 The **`primaryKey`** read-only property of the
 `IDBCursor` interface returns the cursor's current effective key. If the
 cursor is currently being iterated or has iterated outside its range, this is set to
 undefined. The cursor's primary key can be any data type.

**Note:** This feature is available in Web Workers

Value
-----

A value of any data type.

Examples
--------

 In this simple fragment we create a transaction, retrieve an object store, then use a
 cursor to iterate through all the records in the object store. Within each iteration we
 log the primary key of the cursor to the console, something like this (its the album
 title in each case, which is our primarykey):
```

Hemispheres
```


 The cursor does not require us to select the data based
 on a key; we can just grab all of it. Also note that in each iteration of the loop,
 you can grab data from the current record under the cursor object using `cursor.value.foo`. For a complete working example, see our IDBCursor example (View the example live).


```js
function displayData() {
  const transaction = db.transaction(["rushAlbumList"], "readonly");
  const objectStore = transaction.objectStore("rushAlbumList");

  objectStore.openCursor().onsuccess = (event) => {
    const cursor = event.target.result;
    if (cursor) {
      const listItem = document.createElement("li");
      listItem.textContent = `${cursor.value.albumTitle}, ${cursor.value.year}`;
      list.appendChild(listItem);

      console.log(cursor.primaryKey);
      cursor.continue();
    } else {
      console.log("Entries all displayed.");
    }
  };
}
```

Specifications
--------------

| Specification |
| --- |
| Indexed Database API 3.0 # ref-for-dom-idbcursor-primarykey① |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* Using IndexedDB
* Starting transactions: `IDBDatabase`
* Using transactions: `IDBTransaction`
* Setting a range of keys: `IDBKeyRange`
* Retrieving and making changes to your data: `IDBObjectStore`
* Using cursors: `IDBCursor`
* Reference example: To-do Notifications (View the example live).
IDBCursor: key property
=======================

 The **`key`** read-only property of the
 `IDBCursor` interface returns the key for the record at the cursor's
 position. If the cursor is outside its range, this is set to undefined. The cursor's
 key can be any data type.

**Note:** This feature is available in Web Workers

Value
-----

A value of any type.

Examples
--------

 In this simple fragment we create a transaction, retrieve an object store, then use a
 cursor to iterate through all the records in the object store. Within each iteration we
 log the key of the cursor to the console, something like this (its the album title in
 each case, which is our key).

 The cursor does not require us to select the data based
 on a key; we can just grab all of it. Also note that in each iteration of the loop,
 you can grab data from the current record under the cursor object using `cursor.value.foo`. For a complete working example, see our IDBCursor example (View the example live).


```js
function displayData() {
  const transaction = db.transaction(["rushAlbumList"], "readonly");
  const objectStore = transaction.objectStore("rushAlbumList");

  objectStore.openCursor().onsuccess = (event) => {
    const cursor = event.target.result;
    if (cursor) {
      const listItem = document.createElement("li");
      listItem.textContent = `${cursor.value.albumTitle}, ${cursor.value.year}`;
      list.appendChild(listItem);

      console.log(cursor.key);
      cursor.continue();
    } else {
      console.log("Entries all displayed.");
    }
  };
}
```

Specifications
--------------

| Specification |
| --- |
| Indexed Database API 3.0 # ref-for-dom-idbcursor-key① |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* Using IndexedDB
* Starting transactions: `IDBDatabase`
* Using transactions: `IDBTransaction`
* Setting a range of keys: `IDBKeyRange`
* Retrieving and making changes to your data: `IDBObjectStore`
* Using cursors: `IDBCursor`
* Reference example: To-do Notifications (View the example live).
IDBCursor: continue() method
============================

 The **`continue()`** method of the `IDBCursor`
 interface advances the cursor to the next position along its direction, to the item
 whose key matches the optional key parameter. If no key is specified, the cursor
 advances to the immediate next position, based on its direction.

**Note:** This feature is available in Web Workers

Syntax
------


```js
continue()
continue(key)
```

### Parameters

`key` Optional

The key to position the cursor at.

### Return value

None (`undefined`).

### Exceptions

This method may raise a `DOMException` of one of the following types:

`TransactionInactiveError` `DOMException`

Thrown if this IDBCursor's transaction is inactive.

`DataError` `DOMException`

Thrown if the key parameter has any of the following conditions:

* The key is not a valid key.
* The key is less than or equal to this cursor's position, and the cursor's direction is `next` or `nextunique`.
* The key is greater than or equal to this cursor's position and this cursor's direction is `prev` or `prevunique`.

`InvalidStateError` `DOMException`

Thrown if the cursor is currently being iterated or has iterated past its end.

Examples
--------

 In this simple fragment we create a transaction, retrieve an object store, then use a
 cursor to iterate through all the records in the object store. The cursor does not
 require us to select the data based on a key; we can just grab all of it. Also note that
 in each iteration of the loop, you can grab data from the current record under the
 cursor object using `cursor.value.foo`. For a complete working example, see
 our IDBCursor example (View the example live).


```js
function displayData() {
  const transaction = db.transaction(["rushAlbumList"], "readonly");
  const objectStore = transaction.objectStore("rushAlbumList");

  objectStore.openCursor().onsuccess = (event) => {
    const cursor = event.target.result;
    if (cursor) {
      const listItem = document.createElement("li");
      listItem.textContent = `${cursor.value.albumTitle}, ${cursor.value.year}`;
      list.appendChild(listItem);

      cursor.continue();
    } else {
      console.log("Entries all displayed.");
    }
  };
}
```

Specifications
--------------

| Specification |
| --- |
| Indexed Database API 3.0 # ref-for-dom-idbcursor-continue① |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* Using IndexedDB
* Starting transactions: `IDBDatabase`
* Using transactions: `IDBTransaction`
* Setting a range of keys: `IDBKeyRange`
* Retrieving and making changes to your data: `IDBObjectStore`
* Using cursors: `IDBCursor`
* Reference example: To-do Notifications (View the example live).
Permissions: query() method
===========================

The **`Permissions.query()`** method of the `Permissions` interface returns the state of a user permission on the global scope.

Syntax
------


```js
query(permissionDescriptor)
```

### Parameters

`permissionDescriptor`

An object that sets options for the `query` operation consisting of a comma-separated list of name-value pairs. The available options are:

`name`

The name of the API whose permissions you want to query. Each browser supports a different set of values. You'll find Firefox values there, Chromium values there, and WebKit values there.

`userVisibleOnly`

(Push only, not supported in Firefox — see the Browser Support section below) Indicates whether you want to show a notification for every message or be able to send silent push notifications. The default is `false`.

`sysex` (Midi only)

Indicates whether you need and/or receive system exclusive messages. The default is `false`.


**Note:** As of Firefox 44, the permissions for Notifications and Push have been merged. If permission is granted (e.g. by the user, in the relevant permissions dialog), `navigator.permissions.query()` will return `true` for both `notifications` and `push`.

**Note:** The `persistent-storage` permission allows an origin to use a persistent box (i.e., persistent storage) for its storage, as per the Storage API.

### Return value

A `Promise` that resolves to a `PermissionStatus` object.

### Exceptions

`InvalidStateError` `DOMException`

Thrown if `query()` method is invoked in the browsing context and its associated document is not fully active.

`TypeError`

Thrown if retrieving the `PermissionDescriptor` information failed in some way, or the permission doesn't exist or is unsupported by the user agent.

Examples
--------


```js
navigator.permissions.query({ name: "geolocation" }).then((result) => {
  if (result.state === "granted") {
    showLocalNewsWithGeolocation();
  } else if (result.state === "prompt") {
    showButtonToEnableLocalNews();
  }
  // Don't do anything if the permission was denied.
});
```

Specifications
--------------

| Specification |
| --- |
| Permissions # dom-permissions-query |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
Permissions: revoke() method
============================

**Deprecated:** This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.

 The **`Permissions.revoke()`** method of the
 `Permissions` interface reverts a currently set permission back to its
 default state, which is usually `prompt`.
 This method is called on the global `Permissions` object
 `navigator.permissions`.

Syntax
------


```js
revoke(descriptor)
```

### Parameters

`descriptor`

 An object based on the `PermissionDescriptor` dictionary that sets
 options for the operation consisting of a comma-separated list of name-value pairs.
 The available options are:


`name`

 The name of the API whose permissions you want to query.
 Valid values are `'geolocation'`, `'midi'`,
 `'notifications'`, and `'push'`.


`userVisibleOnly`

 (Push only, not supported in Firefox — see the
 Browser compatibility section below) Indicates whether you want to
 show a notification for every message or be able to send silent push
 notifications. The default is `false`.


`sysex` (MIDI only)

 Indicates whether you need and/or receive system
 exclusive messages. The default is `false`.




**Note:** As of Firefox 44, the permissions for Notifications and Push have been merged. If permission is
 granted (e.g. by the user, in the relevant permissions dialog),
 `navigator.permissions.query()` will return `true` for both
 `notifications` and `push`.



**Note:** The `persistent-storage` permission allows an
 origin to use a persistent box (i.e., persistent storage) for its
 storage, as per the Storage API.


### Return value

 A `Promise` that calls its fulfillment handler with a
 `PermissionStatus` object indicating the result of the request.

### Exceptions

`TypeError`

 Retrieving the `PermissionDescriptor` information failed in some way, or
 the permission doesn't exist or is currently unsupported (e.g. `midi`, or
 `push` with `userVisibleOnly`).


Examples
--------

 This function can be used by an app to request that its own Geolocation API permission
 be revoked.


```js
function revokePermission() {
  navigator.permissions.revoke({ name: "geolocation" }).then((result) => {
    report(result.state);
  });
}
```

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
Event: explicitOriginalTarget property
======================================

**Non-standard:** This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.

The read-only **`explicitOriginalTarget`** property of the `Event` interface returns the non-anonymous original target of the event.

If the event was retargeted for some reason other than an anonymous boundary crossing, this will be set to the target before the retargeting occurs.

For example, mouse events are retargeted to their parent node when they happen over text nodes (see Firefox bug 185889), and in that case `currentTarget` will show the parent while this property will show the text node.

This property also differs from `originalTarget` in that it will never contain anonymous content.

Value
-----

Returns the `EventTarget` object, or null if there isn't one.

Example
-------

This property can be used with `<command>` to get the event details of the original object calling the command.


```js
function myCommand(ev) {
  alert(ev.explicitOriginalTarget.nodeName); // returns 'menuitem'
}
```



```xml
<xul:command id="my-cmd-anAction" oncommand="myCommand(event);"/>

<xul:menulist>
  <xul:menupopup>
    <xul:menuitem label="Get my element name!" command="my-cmd-anAction"/>
  </xul:menupopup>
</menulist>
```

Specifications
--------------

*This is a Mozilla-specific property and is not part of any current specification. It is not on track to become a standard.*

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* Comparison of Event Targets
Event: initEvent() method
=========================

**Deprecated:** This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.

 The **`Event.initEvent()`** method is used to initialize the
 value of an `event` created using `Document.createEvent()`.

 Events initialized in this way must have been created with the
 `Document.createEvent()` method.
 This method must be called to set the event
 before it is dispatched, using `EventTarget.dispatchEvent()`.
 Once dispatched, it doesn't do anything anymore.


**Note:** *Do not use this method anymore as it is deprecated.*
 Instead use specific event constructors, like `Event()`.
 The page on Creating and triggering events gives more information about the way to use these.


Syntax
------


```js
event.initEvent(type, bubbles, cancelable)
```

### Parameters

`type`

A string defining the type of event.

`bubbles`

 A boolean value deciding whether the event should bubble up through the
 event chain or not. Once set, the read-only property `Event.bubbles`
 will give its value.


`cancelable`

 A boolean value defining whether the event can be canceled. Once set, the
 read-only property `Event.cancelable` will give its value.


Return value
------------

None.

Example
-------


```js
// Create the event.
const event = document.createEvent("Event");

// Create a click event that bubbles up and
// cannot be canceled
event.initEvent("click", true, false);

// Listen for the event.
elem.addEventListener(
  "click",
  (e) => {
    // e.target matches elem
  },
  false,
);

elem.dispatchEvent(event);
```

Specifications
--------------

| Specification |
| --- |
| DOM Standard # ref-for-dom-event-initevent① |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* The constructor to use instead of this deprecated method:
 `Event()`. To create more specific event interfaces than `Event`, use the constructor defined for the desired event interface.