dist/dom-selection.es.js
function snapSelected(sel) {
	sel = sel || getSelection();
	if (isCollapsed(sel)) { return; }

	var end = sel.focusNode;
	var off = sel.focusOffset;
	var dir = ['forward', 'backward'];
	isBackwards(sel) && dir.reverse();

	// modify() works on the focus of the selection
	sel.collapse(sel.anchorNode, sel.anchorOffset);

	sel.modify('move', dir[0], 'character');
	sel.modify('move', dir[1], 'word');
	sel.extend(end, off);
	sel.modify('extend', dir[1], 'character');
	sel.modify('extend', dir[0], 'word');
}
function snapSelected(sel) {
	sel = sel || getSelection();
	if (isCollapsed(sel)) { return; }

	var end = sel.focusNode;
	var off = sel.focusOffset;
	var dir = ['forward', 'backward'];
	isBackwards(sel) && dir.reverse();

	// modify() works on the focus of the selection
	sel.collapse(sel.anchorNode, sel.anchorOffset);

	sel.modify('move', dir[0], 'character');
	sel.modify('move', dir[1], 'word');
	sel.extend(end, off);
	sel.modify('extend', dir[1], 'character');
	sel.modify('extend', dir[0], 'word');
}
function snapSelected ( sel ) { sel = sel || getSelection ( ) ; if ( isCollapsed ( sel ) ) { return ; } var end = sel . focusNode ; var off = sel . focusOffset ; var dir = [ 'forward' , 'backward' ] ; isBackwards ( sel ) && dir . reverse ( ) ; // modify() works on the focus of the selection sel . collapse ( sel . anchorNode , sel . anchorOffset ) ; sel . modify ( 'move' , dir [ 0 ] , 'character' ) ; sel . modify ( 'move' , dir [ 1 ] , 'word' ) ; sel . extend ( end , off ) ; sel . modify ( 'extend' , dir [ 1 ] , 'character' ) ; sel . modify ( 'extend' , dir [ 0 ] , 'word' ) ; }
Snap the Selection to encompass all partially-selected words.
@see  http://stackoverflow.com/questions/7380190/select-whole-word-with-getselection
@param  {Selection} sel
Snap the Selection to encompass all partially - selected words .