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

restricted-input

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

restricted-input - npm Package Compare versions

Comparing version 1.0.6 to 1.0.7

4

CHANGELOG.md
# Restricted Input - Release Notes
## 1.0.7 (2016-12-16)
* Fix for Samsung keyboards not selecting input correctly after a permacharacter insertion on Android Chrome
## 1.0.6 (2016-12-12)

@@ -4,0 +8,0 @@

31

dist/restricted-input.js

@@ -411,3 +411,2 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.RestrictedInput = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){

var keyCannotMutateValue = require('../key-cannot-mutate-value');
var BaseStrategy = require('./base');

@@ -422,30 +421,3 @@

BaseStrategy.prototype._attachListeners = function () {
var self = this;
self.inputElement.addEventListener('keydown', function (event) {
if (keyCannotMutateValue(event)) { return; }
self._unformatInput(event);
});
self.inputElement.addEventListener('keypress', function (event) {
if (keyCannotMutateValue(event)) { return; }
self._unformatInput(event);
});
self.inputElement.addEventListener('keyup', function (event) {
self._reformatInput(event);
});
self.inputElement.addEventListener('input', function (event) {
console.log('fired input event');
// Safari AutoFill fires CustomEvents -- mark the input as unformatted without actually unformatting the current value
if (event instanceof CustomEvent) {
console.log('fired CustomEvent');
self.isFormatted = false;
}
self._reformatInput(event);
});
self.inputElement.addEventListener('paste', this.pasteEventHandler.bind(this));
};
AndroidChromeStrategy.prototype._prePasteEventHandler = function () {
console.log('in _prePasteEventHandler');
// the default strategy calls preventDefault here

@@ -457,3 +429,2 @@ // but that removes the clipboard data in Android chrome

AndroidChromeStrategy.prototype._postPasteEventHandler = function () {
console.log('in _postPasteEventHandler');
// the default strategy calls this without a timeout

@@ -465,3 +436,3 @@ setTimeout(this._reformatAfterPaste.bind(this), 0);

},{"../key-cannot-mutate-value":9,"./base":12}],12:[function(require,module,exports){
},{"./base":12}],12:[function(require,module,exports){
(function (global){

@@ -468,0 +439,0 @@ 'use strict';

@@ -5,2 +5,4 @@ 'use strict';

var BaseStrategy = require('./base');
var getSelection = require('../input-selection').get;
var setSelection = require('../input-selection').set;

@@ -50,2 +52,23 @@ function AndroidChromeStrategy(options) {

AndroidChromeStrategy.prototype._afterReformatInput = function (formattedState) {
var input = this.inputElement;
// Some Android Chrome keyboards (notably Samsung)
// cause the browser to not know that the value
// of the input has changed when adding
// permacharacters. This results in the selection
// putting the cursor before the permacharacter,
// instead of after. So we setTimeout and check
// the position of the cursor. If it does not match
// the formatted input, we set it again
setTimeout(function () {
var formattedSelection = formattedState.selection;
var selection = getSelection(input);
if (selection.start !== formattedSelection.start) {
setSelection(input, formattedSelection.start, formattedSelection.end);
}
}, 0);
};
module.exports = AndroidChromeStrategy;

@@ -83,4 +83,11 @@ 'use strict';

setSelection(input, formattedState.selection.start, formattedState.selection.end);
this._afterReformatInput(formattedState);
};
// If a strategy needs to impliment specific behavior
// after reformatting has happend, the strategy just
// overwrites this method on their own prototype
BaseStrategy.prototype._afterReformatInput = function () { };
BaseStrategy.prototype._unformatInput = function () {

@@ -87,0 +94,0 @@ var input, unformattedState, selection;

{
"name": "restricted-input",
"version": "1.0.6",
"version": "1.0.7",
"description": "Restrict inputs to certain valid characters (e.g. formatting phone or card numbers)",

@@ -5,0 +5,0 @@ "author": "Braintree <code@getbraintree.com> (https://www.braintreepayments.com/)",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc