Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

input-format

Package Overview
Dependencies
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

input-format - npm Package Compare versions

Comparing version 0.2.4 to 0.2.5

29

commonjs/dom.js

@@ -49,5 +49,30 @@ 'use strict';

// Set caret position
element.setSelectionRange(caret_position, caret_position);
// Set caret position.
// There has been an issue with caret positioning on Android devices.
// https://github.com/catamphetamine/input-format/issues/2
// I was revisiting this issue and looked for similar issues in other libraries.
// For example, there's [`text-mask`](https://github.com/text-mask/text-mask) library.
// They've had exactly the same issue when the caret seemingly refused to be repositioned programmatically.
// The symptoms were the same: whenever the caret passed through a non-digit character of a mask (a whitespace, a bracket, a dash, etc), it looked as if it placed itself one character before its correct position.
// https://github.com/text-mask/text-mask/issues/300
// They seem to have found a basic fix for it: calling `input.setSelectionRange()` in a timeout rather than instantly for Android devices.
// https://github.com/text-mask/text-mask/pull/400/files
// I've implemented the same workaround here.
if (isAndroid()) {
setTimeout(function () {
return element.setSelectionRange(caret_position, caret_position);
}, 0);
} else {
element.setSelectionRange(caret_position, caret_position);
}
}
function isAndroid() {
// `navigator` is not defined when running mocha tests.
if (typeof navigator !== 'undefined') {
return ANDROID_USER_AGENT_REG_EXP.test(navigator.userAgent);
}
}
var ANDROID_USER_AGENT_REG_EXP = /Android/i;
//# sourceMappingURL=dom.js.map

2

commonjs/helpers.js

@@ -10,3 +10,2 @@ 'use strict';

var count = 0;
// Using `.split('')` here instead of normal `for ... of`

@@ -37,5 +36,4 @@ // because the importing application doesn't neccessarily include an ES6 polyfill.

}
return count;
}
//# sourceMappingURL=helpers.js.map

@@ -49,5 +49,30 @@ 'use strict';

// Set caret position
element.setSelectionRange(caret_position, caret_position);
// Set caret position.
// There has been an issue with caret positioning on Android devices.
// https://github.com/catamphetamine/input-format/issues/2
// I was revisiting this issue and looked for similar issues in other libraries.
// For example, there's [`text-mask`](https://github.com/text-mask/text-mask) library.
// They've had exactly the same issue when the caret seemingly refused to be repositioned programmatically.
// The symptoms were the same: whenever the caret passed through a non-digit character of a mask (a whitespace, a bracket, a dash, etc), it looked as if it placed itself one character before its correct position.
// https://github.com/text-mask/text-mask/issues/300
// They seem to have found a basic fix for it: calling `input.setSelectionRange()` in a timeout rather than instantly for Android devices.
// https://github.com/text-mask/text-mask/pull/400/files
// I've implemented the same workaround here.
if (isAndroid()) {
setTimeout(function () {
return element.setSelectionRange(caret_position, caret_position);
}, 0);
} else {
element.setSelectionRange(caret_position, caret_position);
}
}
function isAndroid() {
// `navigator` is not defined when running mocha tests.
if (typeof navigator !== 'undefined') {
return ANDROID_USER_AGENT_REG_EXP.test(navigator.userAgent);
}
}
var ANDROID_USER_AGENT_REG_EXP = /Android/i;
//# sourceMappingURL=dom.js.map

@@ -10,3 +10,2 @@ 'use strict';

var count = 0;
// Using `.split('')` here instead of normal `for ... of`

@@ -37,5 +36,4 @@ // because the importing application doesn't neccessarily include an ES6 polyfill.

}
return count;
}
//# sourceMappingURL=helpers.js.map
{
"name": "input-format",
"version": "0.2.4",
"version": "0.2.5",
"description": "Formatting user's text input on-the-fly",

@@ -5,0 +5,0 @@ "main": "index.commonjs.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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