🚀 Big News:Socket Has Acquired Secure Annex.Learn More →
Socket
Book a DemoSign in
Socket

dialog-toggle-events-polyfill

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dialog-toggle-events-polyfill

This polyfills the `beforetoggle`/`toggle` events for <dialog> elements.

latest
Source
npmnpm
Version
1.1.4
Version published
Weekly downloads
101
5.21%
Maintainers
1
Weekly downloads
 
Created
Source

Dialog Toggle Events polyfill

This polyfills toggle events for the <dialog> element.

Installation

If you're using npm, you only need to import the package, like so:

import "dialog-toggle-events-polyfill";

This will automatically apply the polyfill if required.

If you'd like to manually apply the polyfill, you can instead import the isSupported and apply functions directly from the ./polyfill.js file, which is mapped to /fn:

import { isSupported, apply } from "dialog-toggle-events-polyfill/fn";
if (!isSupported()) apply();

An isPolyfilled function is also available, to detect if it has been polyfilled:

import { isSupported, isPolyfilled, apply } from "dialog-toggle-events-polyfill/fn";
if (!isSupported() && !isPolyfilled()) apply();

Alternatively, if you're not using a package manager, you can use the unpkg script:

<script
  type="module"
  async
  src="https://unpkg.com/dialog-toggle-events-polyfill@latest/index.min.js"
></script>

Usage

With the module imported, you can use beforetoggle and toggle events for dialogs:

<dialog id="mydialog">I'm a dialog!</dialog>
<script>
  mydialog.addEventListener('beforetoggle', console.log)
  mydialog.showModal()
</script>

FAQs

Package last updated on 17 Apr 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts