src/aria/utils/String.js
function (str, options, infos) {
            // -------------------------------------- input arguments processing

            // options ---------------------------------------------------------

            if (options == null) {
                options = true;
            }

            if (!ariaUtilsType.isObject(options)) {
                options = !!options;
                options = {
                    text: options,
                    attr: options
                };
            }

            var escapeForHTMLText = !!(options.text);
            var escapeForHTMLAttr = !!(options.attr);

            // ------------------------------------------------------ processing

            var escaped = false;
            var textEscaped = false;
            var attrEscaped = false;

            if (escapeForHTMLText) {
                escaped = true;
                textEscaped = true;
                str = this.escapeHTML(str).replace(/\//g, "&#x2F;");
            }

            if (escapeForHTMLAttr) {
                escaped = true;
                attrEscaped = true;
                str = this.escapeHTMLAttr(str);
            }

            // ---------------------------------------------------------- return

            if (infos != null) {
                infos.escaped = escaped;
                infos.text = textEscaped;
                infos.attr = attrEscaped;
            }

            return str;
        }
function (str, options, infos) {
            // -------------------------------------- input arguments processing

            // options ---------------------------------------------------------

            if (options == null) {
                options = true;
            }

            if (!ariaUtilsType.isObject(options)) {
                options = !!options;
                options = {
                    text: options,
                    attr: options
                };
            }

            var escapeForHTMLText = !!(options.text);
            var escapeForHTMLAttr = !!(options.attr);

            // ------------------------------------------------------ processing

            var escaped = false;
            var textEscaped = false;
            var attrEscaped = false;

            if (escapeForHTMLText) {
                escaped = true;
                textEscaped = true;
                str = this.escapeHTML(str).replace(/\//g, "&#x2F;");
            }

            if (escapeForHTMLAttr) {
                escaped = true;
                attrEscaped = true;
                str = this.escapeHTMLAttr(str);
            }

            // ---------------------------------------------------------- return

            if (infos != null) {
                infos.escaped = escaped;
                infos.text = textEscaped;
                infos.attr = attrEscaped;
            }

            return str;
        }
function ( str , options , infos ) { // -------------------------------------- input arguments processing // options --------------------------------------------------------- if ( options == null ) { options = true ; } if ( ! ariaUtilsType . isObject ( options ) ) { options = ! ! options ; options = { text : options , attr : options } ; } var escapeForHTMLText = ! ! ( options . text ) ; var escapeForHTMLAttr = ! ! ( options . attr ) ; // ------------------------------------------------------ processing var escaped = false ; var textEscaped = false ; var attrEscaped = false ; if ( escapeForHTMLText ) { escaped = true ; textEscaped = true ; str = this . escapeHTML ( str ) . replace ( / \/ / g , "&#x2F;" ) ; } if ( escapeForHTMLAttr ) { escaped = true ; attrEscaped = true ; str = this . escapeHTMLAttr ( str ) ; } // ---------------------------------------------------------- return if ( infos != null ) { infos . escaped = escaped ; infos . text = textEscaped ; infos . attr = attrEscaped ; } return str ; }
Escape the given string depending on the options. When no options is passed, the escaping is applied for all contexts.

The string can be escaped for different contexts:
<ul>
<li>safe insertion inside an HTML text node</li>
<li>safe insertion inside an attribute value</li>
</ul>



@param {String} str Input string

@param options In its more comprehensive form, it is an object in which each property correspond to a context that can be set to a truthy value to activate escaping (a falsy value, thus including null and undefined, will disable it).
<pre>
{
attr: true, // will escape the string for safe insertion inside the value of an attribute
text: false // will NOT escape the string for safe insertion inside an HTML text node
}
</pre>

There are however two shortcuts that can be used:
<ul>
<li>if nothing is passed, it is equivalent to passing true for all contexts</li>
<li>if something is passed but it's not an object, the value is converted to a boolean (with standard JavaScript coercion), and this boolean value will be used for all contexts.</li>
</ul>

@param {Object} infos An optional object for additional infos on what has been done. For now, tells if it has actually been escaped or not, and for which contexts.

@return {String} processed string
Escape the given string depending on the options . When no options is passed the escaping is applied for all contexts .