npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@webref/events

v1.15.0

Published

Events of the Web platform and associated Web IDL interfaces

Downloads

476

Readme

Events of the Web platform and associated Web IDL interfaces

This package contains a consolidated list of events defined across specs, scraped from the latest versions of web platform specifications in webref, along with the name of the Web IDL interfaces that these events use and target. Fixes are applied to ensure that guarantees hold.

API

The async listAll() method resolves with a list of events. Example:

const events = require('@webref/events');

events.listAll().then(all => {
  for (const event of all) {
    // do something with the json object that describes the event
  }
});

Each event is described by an object with the following properties:

  • type: contains the name of the event
  • interface: describes the IDL interface used by the event
  • targets: lists the target interfaces on which the event may fire. Each target in the list is an object with a target property that gives the interface name, a bubbles property only set when the interface belongs to a bubbling tree to assert whether the event bubbles, and a bubblingPath property only when the event effectively bubbles and that lists the core interfaces on which the event can theoretically bubble.
  • optionally, an href property that is a URL to the event definition in a spec
  • optionally, an src property that describes where the extraction first detected that the event is fired in the spec

The following example illustrates access to main properties:

const events = require('@webref/events');

events.listAll().then(all => {
  for (const event of all) {
    console.log();
    console.log(`Event type=${event.type}
      interface=${event.interface}
      targets=${event.targets
        .map(t => t.target +
          (t.bubbles === undefined ? '' : ` (bubbles: ${t.bubbles})`))
        .join(', ')}`);
  }
});

Actual interfaces on which an event will bubble may be interfaces that inherit from the interfaces listed in bubblingPath. For instance, for a bubbling event that fires on HTMLSelectElement, the bubbling path will be ["Node", "Document", "Window"], even though the event will only bubble on HTMLElement and not on all types of Node in practice.

Guarantees

The following guarantees are provided by this package:

  • All events have a type attribute that match the name of the event
  • All events have a interface attribute to describe the interface used by the Event. The Web IDL interface exists in the latest version of the @webref/idl package at the time the @webref/events package is released, and represents an actual interface (i.e. not a mixin).
  • All events have a targets attribute with a non-empty list of target interfaces on which the event may fire. All Web IDL interfaces in the list exist in the latest version of the @webref/idl package at the time the @webref/events package is released, and represent an actual interface (i.e. not a mixin).
  • The bubbles attribute is always set to a boolean value for target interfaces that belong to a bubbling tree (DOM, IndexedDB, Serial API, Web Bluetooth).
  • The bubbles attribute is only set for target interfaces that belong to a bubbling tree.
  • The bubblingPath attribute is only set for target interfaces on which the event bubbles.
  • The targets attribute contains the top most interfaces in an inheritance chain, unless bubbling conditions differ. For instance, the list may contain { "target": "Element", "bubbles": true } but not also { "target": "HTMLElement", "bubbles": true } since HTMLElement inherits from Element.
  • For target interfaces that belong to a bubbling tree, the targets attribute only contains the deepest interface in the bubbling tree on which the event may fire and bubble. For instance, the list may contain { "target": "HTMLElement", "bubbles": true }, but not also { "target": "Document" } since event would de facto fire at Document through bubbling.