input-number
Advanced tools
Comparing version 1.0.3 to 1.0.4
20
index.js
@@ -12,3 +12,3 @@ /** | ||
}; | ||
const numRE = /[\.0-9]/; | ||
const numRE = /[\-\.0-9]/; | ||
@@ -24,2 +24,4 @@ module.exports = numerify; | ||
var focused = false; | ||
input.addEventListener('keydown', e => { | ||
@@ -35,3 +37,2 @@ let key = keys[e.which]; | ||
//parse left side | ||
@@ -72,3 +73,18 @@ let left = pos.start; | ||
caret.set(input, left, result.length - rightStr.length); | ||
//resurrect suppressed event | ||
let inputEvent = new Event('input'); | ||
input.dispatchEvent(inputEvent); | ||
//emulate change event | ||
if (!focused) { | ||
focused = true; | ||
input.addEventListener('blur', function change () { | ||
input.removeEventListener('blur', change); | ||
let changeEvent = new Event('change'); | ||
input.dispatchEvent(changeEvent); | ||
focused = false; | ||
}); | ||
} | ||
}); | ||
} |
{ | ||
"name": "input-number", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Make input recognize numbers", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3702
64