New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

vanilla-autofill-event

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vanilla-autofill-event

*This is a fork of [autofill-event](https://github.com/tbosch/autofill-event) by TBosch. That shim depends on jQuery on the page this fork does not*

1.0.3
latest
Source
npm
Version published
Weekly downloads
1K
-3.62%
Maintainers
1
Weekly downloads
 
Created
Source

Autofill event polyfill

This is a fork of autofill-event by TBosch. That shim depends on jQuery on the page this fork does not

This is a polyfill that fires change events when browsers autofill form fields without firing a change event.

Install

  • npm install vanilla-autofill-event

Usage

Add the script autofill-event.js,

This will do the following:

  • after DOMContentLoaded: check all input fields
  • a field is left: check all other fields in the same form
document.querySelector('input').addEventListener('change', function(event) {
  console.log('Got a CHANGE');
});

How it works

  • Remember all changes to input elements by the user (listening for change events) and also by JavaScript. That changed value is stored on the element in a private property.

  • Checking an element for auto fill: Compare the current value of the element with the remembered value. If it's different, trigger a change event.

Tests

Unit tests

  • npm install
  • npm test

Manual Tests

  • npm install
  • scripts/webserver.js
  • open the manual runner and follow instructions

Notes:

  • They need to be run with a webserver and without iframes, otherwise Chrome would not autofill username/password

FAQs

Package last updated on 08 Jul 2016

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