Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

An implementation of WHATWG EventTarget interface, plus few extensions.

License

NotificationsYou must be signed in to change notification settings

mysticatea/event-target-shim

Repository files navigation

npm versionDownloads/monthBuild StatusCoverage StatusDependency Status

An implementation ofWHATWGEventTarget interface andWHATWGEvent interface. This implementation supports constructor,passive,once, andsignal.

This implementation is designed ...

  • Working fine on both browsers and Node.js.
  • TypeScript friendly.

Native Support Information:

FeatureIEEdgeFirefoxChromeSafariNode.js
Event constructor121115615.4.0
EventTarget constructor8784871415.4.0
passive option1649511015.4.0
once option1650551015.4.0
signal option

💿 Installation

Usenpm or a compatible tool.

npm install event-target-shim

📖 Getting started

import{EventTarget,Event}from"event-target-shim";// constructor (was added to the standard on 8 Jul 2017)constmyNode=newEventTarget();// passive flag (was added to the standard on 6 Jan 2016)myNode.addEventListener("hello",(e)=>{e.preventDefault();// ignored and print warning on console.},{passive:true});// once flag (was added to the standard on 15 Apr 2016)myNode.addEventListener("hello",listener,{once:true});myNode.dispatchEvent(newEvent("hello"));// remove the listener after call.// signal (was added to the standard on 4 Dec 2020)constac=newAbortController();myNode.addEventListener("hello",listener,{signal:ac.signal});ac.abort();// remove the listener.
  • For browsers, there are two ways:
    • use a bundler such asWebpack to bundle. If you want to support IE11, useimport {} from "event-target-shim/es5" instead. It's a transpiled code by babel. It depends on@baebl/runtime (^7.12.0) package.
    • use CDN such asunpkg.com. For example,<script src="https://unpkg.com/event-target-shim@6.0.2"></script> will defineEventTargetShim global variable.
  • TheAbortController class was added to the standard on 14 Jul 2017. If you want the shim of that, useabort-controller package.

Runnable Examples

📚 API Reference

Seedocs/reference.md.

💥 Migrating to v6

Seedocs/migrating-to-v6.md.

📰 Changelog

SeeGitHub releases.

🍻 Contributing

Contributing is welcome ❤️

Please use GitHub issues/PRs.

Development tools

  • npm install installs dependencies for development.
  • npm test runs tests and measures code coverage.
  • npm run watch:mocha runs tests on each file change.

About

An implementation of WHATWG EventTarget interface, plus few extensions.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Contributors6


[8]ページ先頭

©2009-2025 Movatter.jp