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

focus-options-polyfill

v1.6.0

Published

JavaScript polyfill for the WHATWG spec of focusOptions, that enables a set of options to be passed to the focus method.

Downloads

206,138

Readme

focus-options-polyfill

npm version

JavaScript polyfill for focusOptions, an optional property passed to HTMLElement.focus() that contains the preventScroll boolean, which controls whether the browser should prevent a focused element from being scrolled into view.

Current support

https://caniuse.com/#feat=mdn-api_htmlelement_focus_preventscroll_option

Docs

  • WHATWG Spec

    https://html.spec.whatwg.org/multipage/interaction.html#dom-focusoptions-preventscroll

  • MDN Web Docs - focus

    https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus

Intents to implement

  • Chrome/Chromium: Chrome Platform Status issue 734166 - Prevent scrolling in HTMLElement.focus()

    https://www.chromestatus.com/feature/5745122025144320

  • Edge: Issue 14314565 - Enable ability to prevent scrolling in Element.focus()

    https://web.archive.org/web/20190401133643/https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/14314565/

  • Firefox: Bug 1374045 - Consider adding support for customizing scrolling behavior with Element.focus

    https://bugzilla.mozilla.org/show_bug.cgi?id=1374045

  • Safari: WebKit Bug 178583 - Enable ability to prevent scrolling in Element.focus()

    https://bugs.webkit.org/show_bug.cgi?id=178583

document.scrollingElement

This polyfill uses a basic fallback for the document.scrollingElement property, using document.documentElement when not found.

This could suffice in basic cases, but if you need wider and/or specific support you should refer to a polyfill for it:

  • https://github.com/mathiasbynens/document.scrollingElement

Also, to overcome its absence if you are executing this polyfill through jsdom, you could place this in your setup:

document.scrollingElement = document.documentElement

More context about this property can be found in:

  • https://developer.mozilla.org/en-US/docs/Web/API/Document/scrollingElement
  • https://developer.mozilla.org/en-US/docs/Web/HTML/Quirks_Mode_and_Standards_Mode
  • https://developer.mozilla.org/en-US/docs/Web/API/Document/documentElement

Dev and testing

To check this polyfill you can do:

npm run dev

to launch a small page that will check browser/polyfill behaviour.