function setModernOffsets(node, offsets) {
        if (!window.getSelection) {
            return;
        }

        var selection = window.getSelection();
        var length = node.textContent.length;
        var start = Math.min(offsets.start, length);
        var end = offsets.end === undefined
            ? start
            : Math.min(offsets.end, length);

        // IE 11 uses modern selection, but doesn"t support the extend method. Flip
        // backward selections, so we can set with a single range.
        if (!selection.extend && start > end) {
            var temp = end;
            end = start;
            start = temp;
        }

        var startMarker = getNodeForCharacterOffset(node, start);
        var endMarker = getNodeForCharacterOffset(node, end);

        if (startMarker && endMarker) {
            var range = document.createRange();
            range.setStart(startMarker.node, startMarker.offset);
            selection.removeAllRanges();

            if (start > end) {
                selection.addRange(range);
                selection.extend(endMarker.node, endMarker.offset);
            } else {
                range.setEnd(endMarker.node, endMarker.offset);
                selection.addRange(range);
            }
        }
    }
In modern non-IE browsers, we can support both forward and backward
selections.

Note: IE10+ supports the Selection object, but it does not support
the `extend` method, which means that even in modern IE, it"s not possible
to programmatically create a backward selection. Thus, for all IE
versions, we use the old IE API to create our selections.

@param {DOMElement|DOMTextNode} node
@param {object} offsets