
Product
Introducing Module Reachability: Focus on the Vulnerabilities That Matter
Module Reachability filters out unreachable CVEs so you can focus on vulnerabilities that actually matter to your application.
selection-update
Advanced tools
Computing selection updates on external INPUT value changes, browser style
Computing input selection updates on external content changes, as if we used browser managed undo and redo.
/**
* Calculate the selection update for the given
* current and new input values.
*
* @param {Object} currentSelection as {start, end}
* @param {String} currentValue
* @param {String} newValue
*
* @return {Object} newSelection as {start, end}
*/
calculateUpdate(currentSelection, currentValue, newValue);
import { calculateUpdate } from 'selection-update';
/**
* Update input with new value.
* @param {Node} $input
* @param {String} newValue
*/
function updateInput($input, newValue) {
var newSelection;
// only retrieve and restore input, if the element
// is currently active
if (document.activeElement === $input) {
// get the current selection and pass it in as {start, end}
newSelection = selectionUpdate(getSelection($input), $input.value, newValue);
}
// apply new value, will naturally send selection to input end
$input.value = value;
if (newSelection) {
// set new {start, end} selection on input
setSelection($input, selection);
}
}
MIT
1.0.0
CHORE
: turn into moduleCHORE
: export contents via named exportsFAQs
Computing selection updates on external INPUT value changes, browser style
The npm package selection-update receives a total of 18,314 weekly downloads. As such, selection-update popularity was classified as popular.
We found that selection-update demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Module Reachability filters out unreachable CVEs so you can focus on vulnerabilities that actually matter to your application.
Company News
Socket is bringing best-in-class reachability analysis into the platform — cutting false positives, accelerating triage, and cementing our place as the leader in software supply chain security.
Product
Socket is introducing a new way to organize repositories and apply repository-specific security policies.