seleccion

2.0.0 • Public • Published

seleccion

A getSelection polyfill and a setSelection dreamweaver

Includes also a setSelection method. See also [sell][2] to work with selection within <input> and <textarea> elements.

install

npm install seleccion

seleccion.getSelection

Provides a polyfill for window.getSelection.

var getSelection = require('seleccion').get;
  • Defaults to window.getSelection if available
  • Falls back to document.selection
  • Falls back to a naïve null object if both are unavailable

seleccion.set(range)

Provides a convenient cross-browser method to set the text selection into range.

var setSelection = require('seleccion').set;
setSelection({
  startContainer: document.querySelector('#some-span'),
  startOffset: 0,
  endContainer: document.querySelector('#another-span'),
  endOffset: 24,
  collapsed: false
});

license

MIT

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 2.0.0
    3,975
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 2.0.0
    3,975
  • 1.0.0
    1

Package Sidebar

Install

npm i seleccion

Weekly Downloads

3,976

Version

2.0.0

License

MIT

Last publish

Collaborators

  • bevacqua