set-caret-position
Advanced tools
Comparing version 2.0.1 to 3.0.0
14
index.js
module.exports = function (inputField, caretPos) { | ||
if (inputField.createTextRange) { | ||
var range = inputField.createTextRange(); | ||
var element = document.getElementById(inputField); | ||
if (element.createTextRange) { | ||
var range = element.createTextRange(); | ||
range.move('character', caretPos); | ||
range.select(); | ||
} else { | ||
if (inputField.selectionStart || inputField.selectionStart === 0) { | ||
inputField.focus(); | ||
inputField.setSelectionRange(caretPos, caretPos); | ||
if (element.selectionStart || element.selectionStart === 0) { | ||
element.focus(); | ||
element.setSelectionRange(caretPos, caretPos); | ||
} else { | ||
inputField.focus(); | ||
element.focus(); | ||
} | ||
} | ||
}; | ||
{ | ||
"name": "set-caret-position", | ||
"version": "2.0.1", | ||
"version": "3.0.0", | ||
"description": "Move cursor to beginning of line below", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
var setCaretPosition = require('./index.js'); | ||
document = { | ||
getElementById: function() { | ||
return element; | ||
} | ||
}; | ||
var element = { | ||
@@ -4,0 +11,0 @@ range: { |
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
1437
33