MCPcopy Create free account
hub / github.com/breck7/scroll / restoreSelection

Function restoreSelection

external/.scrollLibs.js:5885–5899  ·  view source on GitHub ↗
(snapshot)

Source from the content-addressed store, hash-verified

5883 }
5884
5885 function restoreSelection(snapshot) {
5886 if (!snapshot || !snapshot.activeElt || snapshot.activeElt == activeElt()) {
5887 return
5888 }
5889 snapshot.activeElt.focus()
5890 if (snapshot.anchorNode && contains(document.body, snapshot.anchorNode) && contains(document.body, snapshot.focusNode)) {
5891 var sel = window.getSelection(),
5892 range$$1 = document.createRange()
5893 range$$1.setEnd(snapshot.anchorNode, snapshot.anchorOffset)
5894 range$$1.collapse(false)
5895 sel.removeAllRanges()
5896 sel.addRange(range$$1)
5897 sel.extend(snapshot.focusNode, snapshot.focusOffset)
5898 }
5899 }
5900
5901 // Does the actual updating of the line display. Bails out
5902 // (returning false) when there is nothing to be done and forced is

Callers 1

updateDisplayIfNeededFunction · 0.85

Calls 3

activeEltFunction · 0.85
extendMethod · 0.80
containsFunction · 0.70

Tested by

no test coverage detected