src/aria/utils/Caret.js
function (element) {
            var pos = {
                start : 0,
                end : 0
            };

            if ("selectionStart" in element) {
                // w3c standard, available in all but IE<9
                pos.start = element.selectionStart;
                pos.end = element.selectionEnd;
            } else {
                // old IE support
                var document = Aria.$window.document;
                if (document.selection) {
                    var sel = document.selection.createRange();
                    var initialLength = sel.text.length;
                    sel.moveStart('character', -element.value.length);
                    var x = sel.text.length;
                    pos.start = x - initialLength;
                    pos.end = x;
                }
            }

            return pos;
        }
function (element) {
            var pos = {
                start : 0,
                end : 0
            };

            if ("selectionStart" in element) {
                // w3c standard, available in all but IE<9
                pos.start = element.selectionStart;
                pos.end = element.selectionEnd;
            } else {
                // old IE support
                var document = Aria.$window.document;
                if (document.selection) {
                    var sel = document.selection.createRange();
                    var initialLength = sel.text.length;
                    sel.moveStart('character', -element.value.length);
                    var x = sel.text.length;
                    pos.start = x - initialLength;
                    pos.end = x;
                }
            }

            return pos;
        }
function ( element ) { var pos = { start : 0 , end : 0 } ; if ( "selectionStart" in element ) { // w3c standard, available in all but IE<9 pos . start = element . selectionStart ; pos . end = element . selectionEnd ; } else { // old IE support var document = Aria . $window . document ; if ( document . selection ) { var sel = document . selection . createRange ( ) ; var initialLength = sel . text . length ; sel . moveStart ( 'character' , - element . value . length ) ; var x = sel . text . length ; pos . start = x - initialLength ; pos . end = x ; } } return pos ; }
Return the caret position of the HTML element
@param {HTMLElement} element The html element
@return {Object} The caret position (start and end)
Return the caret position of the HTML element