dist/dom-selection.es.js
function getNodes(sel) {
	var range = getRange(sel);
	if (!range) { return []; }

	var node = range.startContainer;
	var endNode = range.endContainer;

	// Special case for a range that is contained within a single node
	if (node === endNode) { return [node]; }

	// Iterate nodes until we hit the end container
	var nodes = [];
	while (node && node !== endNode) {
		nodes.push(node = nextNode(node));
	}

	// Add partially selected nodes at the start of the range
	node = range.startContainer;
	while (node && node !== range.commonAncestorContainer) {
		nodes.unshift(node);
		node = node.parentNode;
	}

	return nodes;
}
function getNodes(sel) {
	var range = getRange(sel);
	if (!range) { return []; }

	var node = range.startContainer;
	var endNode = range.endContainer;

	// Special case for a range that is contained within a single node
	if (node === endNode) { return [node]; }

	// Iterate nodes until we hit the end container
	var nodes = [];
	while (node && node !== endNode) {
		nodes.push(node = nextNode(node));
	}

	// Add partially selected nodes at the start of the range
	node = range.startContainer;
	while (node && node !== range.commonAncestorContainer) {
		nodes.unshift(node);
		node = node.parentNode;
	}

	return nodes;
}
function getNodes ( sel ) { var range = getRange ( sel ) ; if ( ! range ) { return [ ] ; } var node = range . startContainer ; var endNode = range . endContainer ; // Special case for a range that is contained within a single node if ( node === endNode ) { return [ node ] ; } // Iterate nodes until we hit the end container var nodes = [ ] ; while ( node && node !== endNode ) { nodes . push ( node = nextNode ( node ) ) ; } // Add partially selected nodes at the start of the range node = range . startContainer ; while ( node && node !== range . commonAncestorContainer ) { nodes . unshift ( node ) ; node = node . parentNode ; } return nodes ; }
Get all Nodes within a Selection.
@see http://stackoverflow.com/questions/7781963/js-get-array-of-all-selected-nodes-in-contenteditable-div
@param  {Selection} sel
@return {Array}
Get all Nodes within a Selection .