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 🙏

© 2026 – Pkg Stats / Ryan Hefner

select-events

v0.1.0

Published

Adding open / close events for SELECT elements, so script code can listen for a select's picker dropdown being shown or hidden

Readme

select-events

This package adds open / close events for HTML <select> elements. Script code can then use regular DOM event listeners to run code when a select's picker dropdown is being shown or hidden.

usage

Import the package into your main script or add it via a <script> tag to your HTML document.

import "select-events/non-standard-open-close";

This automatically adds support for open and close events. The open event type is --select-open. The close event type is --select-close. Both events bubble. The event args object does not have any special properties; only the standard properties that are shared by all DOM events, like target etc.

// listening for open events directly at the element
const selectElement = document.querySelector('select');
selectElement.addEventListener('--select-open', () => { console.log('This picker opened!'); });

// listening for bubbling close events at the document root
document.addEventListener('--select-close', () => { console.log('Some picker closed!'); });

Why the weird naming?

You might wonder why the import path must be select-events/non-standard-open-close and why the event types are prefixed with two dashes. The reason is that the open and close events for <select> elements are not yet part of the HTML standard and there is an open discussion to clarify how exactly the events will look and feel (what name will they have? what timing? cancelable? will they be paired with other events? how will the event args look?). The longish import path thus a) makes it perfectly clear that it adds a non-standard feature and b) allows for a future version of this package to use the shorter import path select-events to polyfill the officially sanctioned events once the standard has landed. The two dashes infront of the event types mark them as values that are defined in userland (as opposed to native values which never start with two dashes). This prevents potential future name conflicts (e.g. "SmooshGate") should the standard add native values with the same name.

What should work? How does it work?

When initialized the package queries and processes all <select> elements on the page, including all that are currently in the DOM when the init code runs, but also processing all future <select> elements that will be created at any point in time and added to the DOM. It also handles <select> elements in shadow DOM. Any content of <iframe> elements is not processed. Processed elements are observed by a watcher that utilizes the css feature select:open to determine whether the dropdown is open or closed. A StyleObserver mechanism will be triggered when the css selector matches, and will execute a callback that finally raises the DOM events.

Feedback

Please don't hesitate to provide feedback by opening an issue or a discussion. If you find a bug or experience that the package isn't working as expected please let me know. I can only fix those bugs I am made aware of.