4.2. Event interfaces

This specification fires events with the following custom interfaces:

  1. [Exposed=(Window,Worker),
  2. Constructor(DOMString type, optional IDBVersionChangeEventInit eventInitDict)]
  3. interface IDBVersionChangeEvent : Event {
  4. readonly attribute unsigned long long oldVersion;
  5. readonly attribute unsigned long long? newVersion;
  6. };
  7.  
  8. dictionary IDBVersionChangeEventInit : EventInit {
  9. unsigned long long oldVersion = 0;
  10. unsigned long long? newVersion = null;
  11. };

The oldVersion attribute getter returns the previous version of the database.

The newVersion attribute getter returns the new version of the database, or null if the database is being deleted. See the steps to run an upgrade transaction.

Events are constructed as defined in Constructing events, in [DOM41].

To fire a version change event named e at target given oldVersion and newVersion, run these steps:

  1. Let event be the result of creating an event using [IDBVersionChangeEvent](#idbversionchangeevent).

  2. Set event’s [type](https://www.w3.org/TR/dom41/#dom-event-type) attribute to e.

  3. Set event’s [bubbles](https://www.w3.org/TR/dom41/#dom-event-bubbles) and [cancelable](https://www.w3.org/TR/dom41/#dom-event-cancelable) attributes to false.

  4. Set event’s [oldVersion](#dom-idbversionchangeevent-oldversion) attribute to oldVersion.

  5. Set event’s [newVersion](#dom-idbversionchangeevent-newversion) attribute to newVersion.

  6. Let legacyOutputDidListenersThrowFlag be unset.

  7. Dispatch event at target with legacyOutputDidListenersThrowFlag.

  8. Return legacyOutputDidListenersThrowFlag.

    The return value of this algorithm is not always used.