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

detect-autofill

v1.1.4

Published

Small javascript library to detect and even prevent browsers autofill of form elements. Usefull for implementing floating labels or applying custom logics/styles.

Downloads

118,304

Readme

Detect browsers autofill

npm version Build Status David David Greenkeeper badge License: MIT

TLDR

  1. Import script in the head
<head>
  ...
  <script src="https://unpkg.com/detect-autofill/dist/detect-autofill.js"></script>
  ...
</head>
  1. add event listeners
  2. do your things...
document.addEventListener('onautocomplete', function(e) {
  e.target.hasAttribute('autocompleted'); // true or false
  e.preventDefault(); // prevent autocomplete
  // do you stuff...
})

Getting Started

Small javascript library to detect browser autofill of form elements. Usefull for implementing floating labels or appling custom styles.

Modern browsers all have some ability to autocomplete the forms in a web page. It can be a login or a registration form, and the autofill can be triggered automatiaclly by the browser or manually by the user. In both cases there is no native way to detect the autocomplete. This is where this small library comes in handy.

Every browser has it's own way to autocomplete a form. Basically this library creates and triggers a CustomEvent called autocomplete every time this happends.

Furthermore this custom event can be prevented like all native events in order to block browser autofill using e.preventDefault().

Features

  • Polyfill for CustomEvent integrated
  • CustomEvent on onautocomplete
  • CustomEvent on onautocomplete cancel
  • Possibility to prevent onautocomplete

Browser Support

| CustomEvent | Edge | IE11 | Chrome | Firefox | Safari | Opera | iOS | | -------------- |:----:|:-----:|:------:|:-------:|:------:|:-----:|:---:| | onautocomplete | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |

* This script uses different technics to detect autofill based on the browser:

  • Chrome, Opera and Safari uses the pseudo-class :-webkit-autofill to trigger a custom animation.
  • Firefox uses input event on document and checks for a propriety inputType property of the event.
  • IE, Edge and iOS uses the same input event but they have to check the data property.
  • Android ha not yet been tested any help is welcomed.

Demos

The demos can be tested on every browser. If something is not working properly, please open an issue or a PR.

| Title | Source code | Live demo | | ----- | ----------- | --------- | | Fake login page | Code | Live |