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

normify-listeners

v1.0.0

Published

Makes event APIs behave in the standard way

Downloads

7

Readme

normify-listeners

Makes event APIs behave in the standard way

Installation

Install with npm:

npm install --save normify-listeners

Usage

However you use the normify-listeners module, it is important that you call it before any of your other code so that its fixes are applied first.

CommonJS require():

require('normify-listeners')();

ES2015 import:

import normifyListeners from 'normify-listeners';

normifyListeners();

Browser globals:

Download normify-listeners.js from the dist directory, and include in your HTML file:

<script src="normify-listeners.js"></script>
<script>normifyListeners();</script>

AMD:

Use normify-listeners.js from the dist directory:

require( ['normify-listeners'], function( normifyListeners ){
  normifyListeners();
} );

Options

The normifyListeners( options ) function takes an options object with the following fields:

  • domOnly: If true (default), only window, document, and Element are patched. If false, only EventTarget is patched. Since EventTarget affects other prototypes like AudioContext and known issues only affect DOM objects, it's probably safer to use domOnly: true.

Known issues this lib resolves

  • Chrome 56 breaks support for the EventTarget.addEventListener function. Chrome assumes that all touch events should be passive unless explicitly specified otherwise --- even though older apps wouldn't be aware of the options parameter to addEventListener(). This makes all calls to event.preventDefault() fail.
    • The addEventListener() function is normalised to make browsers that assume nonstandard behaviour use the correct, default options. The addEventListener() function is wrapped, passing the default options explicitly (options = { capture: false, once: false, passive: false }). This makes Chrome behave in line with standard, well-established behaviour: event.preventDefault() works properly by default, as it always has done.
    • References: W3C DOM Living Standard, Chromium bug #639227, WICG/interventions#18
  • The addition of the options parameter to the addEventListener() function means that passing a function could be misinterpreted by older browsers as useCapture == true.
    • Browser support for the options parameter of addEventListener() is checked in tandem with the third argument of addEventListener. This means you can always use the options parameter without having to worry about old browsers misinterpreting it as useCapture == true.