
Research
/Security News
Fake imToken Chrome Extension Steals Seed Phrases via Phishing Redirects
Mixed-script homoglyphs and a lookalike domain mimic imToken’s import flow to capture mnemonics and private keys.
dom-input-range
Advanced tools
InputRangeThe Range web API provides access to a slice of a document, including some very useful functions for obtaining the coordinates of the contents of that slice (getClientRects and getBoundingClientRect).
These could be extremely powerful when used in tandem with form input fields as they can allow for annotating text without having to wrap it in a span. Unfortunately, the contents of <input> and <textarea> elements remain inaccessible to this API because they are not rendered like regular Text nodes.
This library aims to provide a solution to that through a new InputRange class that implements a subset of the Range API.

Install the package:
npm install dom-input-range
A new InputRange can be constructed with an element and offsets. For example, to get the coordinates of the bounding box around the first ten characters of a textarea:
import { InputRange } from "dom-input-range";
new InputRange(element, 0, 10).getBoundingClientRect();
There is also a convenient fromSelection method for creating a range from the active selection. This can also be used to get the coordinates of the caret:
import { InputRange } from "dom-input-range";
InputRange.fromSelection(element).getClientRects();
For the full api, see the docs for InputRange.
<textarea> to see the difference between getBoundingClientRect and getClientRectsThis API is focused on providing an intuitive way to obtain the coordinates of text inside a form field element. It also implements a few other Range methods for consistency with the browser API, but it does not implement the entire class:
InputRange cannot cross Node boundaries, so any method that works with Nodes is not implementedsetStartOffset and setEndOffsetvalue directly insteadInputStyleClone low-level APIBehind the scenes, InputRange works by creating a 'clone' element that copies all of the styling and contents from the input element. This clone is then appended to the document and hidden from view so it can be queried. This low-level API is exposed as InputStyleClone for advanced use cases:
const clone = new InputStyleClone(input)
clone.element.getBoundingClientRect()
Mounting a new element and copying styles can have a real performance impact, and this API has been carefully designed to minimize that. You can use InputStyleClone.for to share a single default clone instance for the lifetime of an input, if you only plan to query and not mutate the clone element:
const sharedClone = InputStyleClone.for(input)
clone.element.getBoundingClientRect()
FAQs
Range-like API for input and textarea contents
The npm package dom-input-range receives a total of 4,665 weekly downloads. As such, dom-input-range popularity was classified as popular.
We found that dom-input-range demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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.

Research
/Security News
Mixed-script homoglyphs and a lookalike domain mimic imToken’s import flow to capture mnemonics and private keys.

Security News
Latio’s 2026 report recognizes Socket as a Supply Chain Innovator and highlights our work in 0-day malware detection, SCA, and auto-patching.

Company News
Join Socket for live demos, rooftop happy hours, and one-on-one meetings during BSidesSF and RSA 2026 in San Francisco.