Socket
Socket
Sign inDemoInstall

set-caret-position

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

set-caret-position - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0

22

index.js
module.exports = function (inputField, caretPos) {
if (inputField != null) {
if (inputField[0].createTextRange) {
var range = inputField[0].createTextRange();
range.move('character', caretPos);
range.select();
if (inputField.createTextRange) {
var range = inputField.createTextRange();
range.move('character', caretPos);
range.select();
} else {
if (inputField.selectionStart || $(inputField).selectionStart ===
0) {
inputField.focus();
inputField.setSelectionRange(caretPos, caretPos);
} else {
if (inputField[0].selectionStart || $(inputField)[0].selectionStart ===
0) {
inputField[0].focus();
inputField[0].setSelectionRange(caretPos, caretPos);
} else {
inputField[0].focus();
}
inputField.focus();
}
}
};
{
"name": "set-caret-position",
"version": "1.0.0",
"description": "Set caret to position in input area",
"version": "2.0.0",
"description": "Move cursor to beginning of line below",
"main": "index.js",

@@ -22,3 +22,4 @@ "scripts": {

}
], "license": "MIT"
],
"license": "MIT"
}
#set-caret-position
Selection or full line of text if nothing selected.
Move cursor to beginning of line below.
var setCaretPosition = require('./index.js');
setCaretPosition();
var element = {
range: {
move: function () {
},
select: function () {
}
},
createTextRange: function () {
return this.range
}
};
setCaretPosition(element);
console.log('Done testing. All good');
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