src/language/HTMLUtils.js
function getTagAttributes(editor, pos) {
        var attrs       = [],
            backwardCtx = TokenUtils.getInitialContext(editor._codeMirror, pos),
            forwardCtx  = $.extend({}, backwardCtx);

        if (editor.getModeForSelection() === "html") {
            if (backwardCtx.token && !tagPrefixedRegExp.test(backwardCtx.token.type)) {
                while (TokenUtils.movePrevToken(backwardCtx) && !tagPrefixedRegExp.test(backwardCtx.token.type)) {
                    if (backwardCtx.token.type === "error" && backwardCtx.token.string.indexOf("<") === 0) {
                        break;
                    }
                    if (backwardCtx.token.type === "attribute") {
                        attrs.push(backwardCtx.token.string);
                    }
                }

                while (TokenUtils.moveNextToken(forwardCtx) && !tagPrefixedRegExp.test(forwardCtx.token.type)) {
                    if (forwardCtx.token.type === "attribute") {
                        // If the current tag is not closed, codemirror may return the next opening
                        // tag as an attribute. Stop the search loop in that case.
                        if (forwardCtx.token.string.indexOf("<") === 0) {
                            break;
                        }
                        attrs.push(forwardCtx.token.string);
                    } else if (forwardCtx.token.type === "error") {
                        if (forwardCtx.token.string.indexOf("<") === 0 || forwardCtx.token.string.indexOf(">") === 0) {
                            break;
                        }
                        // If we type the first letter of the next attribute, it comes as an error
                        // token. We need to double check for possible invalidated attributes.
                        if (/\S/.test(forwardCtx.token.string) &&
                                forwardCtx.token.string.indexOf("\"") === -1 &&
                                forwardCtx.token.string.indexOf("'") === -1 &&
                                forwardCtx.token.string.indexOf("=") === -1) {
                            attrs.push(forwardCtx.token.string);
                        }
                    }
                }
            }
        }

        return attrs;
    }
function getTagAttributes(editor, pos) {
        var attrs       = [],
            backwardCtx = TokenUtils.getInitialContext(editor._codeMirror, pos),
            forwardCtx  = $.extend({}, backwardCtx);

        if (editor.getModeForSelection() === "html") {
            if (backwardCtx.token && !tagPrefixedRegExp.test(backwardCtx.token.type)) {
                while (TokenUtils.movePrevToken(backwardCtx) && !tagPrefixedRegExp.test(backwardCtx.token.type)) {
                    if (backwardCtx.token.type === "error" && backwardCtx.token.string.indexOf("<") === 0) {
                        break;
                    }
                    if (backwardCtx.token.type === "attribute") {
                        attrs.push(backwardCtx.token.string);
                    }
                }

                while (TokenUtils.moveNextToken(forwardCtx) && !tagPrefixedRegExp.test(forwardCtx.token.type)) {
                    if (forwardCtx.token.type === "attribute") {
                        // If the current tag is not closed, codemirror may return the next opening
                        // tag as an attribute. Stop the search loop in that case.
                        if (forwardCtx.token.string.indexOf("<") === 0) {
                            break;
                        }
                        attrs.push(forwardCtx.token.string);
                    } else if (forwardCtx.token.type === "error") {
                        if (forwardCtx.token.string.indexOf("<") === 0 || forwardCtx.token.string.indexOf(">") === 0) {
                            break;
                        }
                        // If we type the first letter of the next attribute, it comes as an error
                        // token. We need to double check for possible invalidated attributes.
                        if (/\S/.test(forwardCtx.token.string) &&
                                forwardCtx.token.string.indexOf("\"") === -1 &&
                                forwardCtx.token.string.indexOf("'") === -1 &&
                                forwardCtx.token.string.indexOf("=") === -1) {
                            attrs.push(forwardCtx.token.string);
                        }
                    }
                }
            }
        }

        return attrs;
    }
function getTagAttributes ( editor , pos ) { var attrs = [ ] , backwardCtx = TokenUtils . getInitialContext ( editor . _codeMirror , pos ) , forwardCtx = $ . extend ( { } , backwardCtx ) ; if ( editor . getModeForSelection ( ) === "html" ) { if ( backwardCtx . token && ! tagPrefixedRegExp . test ( backwardCtx . token . type ) ) { while ( TokenUtils . movePrevToken ( backwardCtx ) && ! tagPrefixedRegExp . test ( backwardCtx . token . type ) ) { if ( backwardCtx . token . type === "error" && backwardCtx . token . string . indexOf ( "<" ) === 0 ) { break ; } if ( backwardCtx . token . type === "attribute" ) { attrs . push ( backwardCtx . token . string ) ; } } while ( TokenUtils . moveNextToken ( forwardCtx ) && ! tagPrefixedRegExp . test ( forwardCtx . token . type ) ) { if ( forwardCtx . token . type === "attribute" ) { // If the current tag is not closed, codemirror may return the next opening // tag as an attribute. Stop the search loop in that case. if ( forwardCtx . token . string . indexOf ( "<" ) === 0 ) { break ; } attrs . push ( forwardCtx . token . string ) ; } else if ( forwardCtx . token . type === "error" ) { if ( forwardCtx . token . string . indexOf ( "<" ) === 0 || forwardCtx . token . string . indexOf ( ">" ) === 0 ) { break ; } // If we type the first letter of the next attribute, it comes as an error // token. We need to double check for possible invalidated attributes. if ( / \S / . test ( forwardCtx . token . string ) && forwardCtx . token . string . indexOf ( "\"" ) === - 1 && forwardCtx . token . string . indexOf ( "'" ) === - 1 && forwardCtx . token . string . indexOf ( "=" ) === - 1 ) { attrs . push ( forwardCtx . token . string ) ; } } } } } return attrs ; }
Compiles a list of used attributes for a given tag
@param {CodeMirror} editor An instance of a CodeMirror editor
@param {ch:{string}, line:{number}} pos A CodeMirror position
@return {Array.<string>} A list of the used attributes inside the current tag
Compiles a list of used attributes for a given tag