src/aria/utils/Dom.js
function (idOrElt, newHTML) {

            // PROFILING // var msr1 = this.$startMeasure("ReplaceHTML");
            var domElt = idOrElt;
            if (typeof(domElt) == "string") {
                domElt = this.getElementById(domElt);
            }
            if (domElt) {
                if ((ariaCoreBrowser.isIE7 || ariaCoreBrowser.isIE8) && aria.utils && aria.utils.Delegate) {
                    try {
                        var activeElement = Aria.$window.document.activeElement;
                        if (activeElement && this.isAncestor(activeElement, domElt)) {
                            // On IE 7-8, there is an issue after removing from the DOM a focused element.
                            // We detect it here so that next time there is a need to focus an element, we focus the
                            // body first (which is the work-around for IE 7-8)
                            aria.utils.Delegate.ieRemovingFocusedElement();
                        }
                    } catch (e) {
                        // on (real) IE8, an "Unspecified error" can be raised when trying to read
                        // Aria.$window.document.activeElement
                        // It happens when executing the following test: test.aria.utils.cfgframe.AriaWindowTest
                        // It does not happen with IE 11 in IE8 mode.
                    }
                }
                // PROFILING // var msr2 = this.$startMeasure("RemoveHTML");
                // TODO: check HTML for security (no script ...)
                try {
                    domElt.innerHTML = ""; // this makes IE run faster (!)
                    // PROFILING // this.$stopMeasure(msr2);
                    domElt.innerHTML = newHTML;
                } catch (ex) {
                    // PTR 04429212:
                    // IE does not support setting the innerHTML property of tbody, tfoot, thead or tr elements
                    // directly. We use a simple work-around:
                    // create a complete table, get the HTML element and insert it in the DOM
                    var newDomElt = this._createTableElement(domElt.tagName, newHTML, domElt.ownerDocument);
                    if (newDomElt) {
                        this.replaceDomElement(domElt, newDomElt);
                        this.copyAttributes(domElt, newDomElt);
                        domElt = newDomElt;
                    } else {
                        // propagate the exception
                        throw ex;
                    }
                }
                // PROFILING // var msr3 = this.$startMeasure("contentchange");
                // use the delegate manager to forward a fake event
                if (aria.utils && aria.utils.Delegate) {
                    aria.utils.Delegate.delegate(aria.DomEvent.getFakeEvent('contentchange', domElt));
                }
                // PROFILING // this.$stopMeasure(msr3);
            } else {
                this.$logError(this.DIV_NOT_FOUND, [idOrElt]);
                return null;
            }
            // PROFILING // this.$stopMeasure(msr1);
            return domElt;
        }
function (idOrElt, newHTML) {

            // PROFILING // var msr1 = this.$startMeasure("ReplaceHTML");
            var domElt = idOrElt;
            if (typeof(domElt) == "string") {
                domElt = this.getElementById(domElt);
            }
            if (domElt) {
                if ((ariaCoreBrowser.isIE7 || ariaCoreBrowser.isIE8) && aria.utils && aria.utils.Delegate) {
                    try {
                        var activeElement = Aria.$window.document.activeElement;
                        if (activeElement && this.isAncestor(activeElement, domElt)) {
                            // On IE 7-8, there is an issue after removing from the DOM a focused element.
                            // We detect it here so that next time there is a need to focus an element, we focus the
                            // body first (which is the work-around for IE 7-8)
                            aria.utils.Delegate.ieRemovingFocusedElement();
                        }
                    } catch (e) {
                        // on (real) IE8, an "Unspecified error" can be raised when trying to read
                        // Aria.$window.document.activeElement
                        // It happens when executing the following test: test.aria.utils.cfgframe.AriaWindowTest
                        // It does not happen with IE 11 in IE8 mode.
                    }
                }
                // PROFILING // var msr2 = this.$startMeasure("RemoveHTML");
                // TODO: check HTML for security (no script ...)
                try {
                    domElt.innerHTML = ""; // this makes IE run faster (!)
                    // PROFILING // this.$stopMeasure(msr2);
                    domElt.innerHTML = newHTML;
                } catch (ex) {
                    // PTR 04429212:
                    // IE does not support setting the innerHTML property of tbody, tfoot, thead or tr elements
                    // directly. We use a simple work-around:
                    // create a complete table, get the HTML element and insert it in the DOM
                    var newDomElt = this._createTableElement(domElt.tagName, newHTML, domElt.ownerDocument);
                    if (newDomElt) {
                        this.replaceDomElement(domElt, newDomElt);
                        this.copyAttributes(domElt, newDomElt);
                        domElt = newDomElt;
                    } else {
                        // propagate the exception
                        throw ex;
                    }
                }
                // PROFILING // var msr3 = this.$startMeasure("contentchange");
                // use the delegate manager to forward a fake event
                if (aria.utils && aria.utils.Delegate) {
                    aria.utils.Delegate.delegate(aria.DomEvent.getFakeEvent('contentchange', domElt));
                }
                // PROFILING // this.$stopMeasure(msr3);
            } else {
                this.$logError(this.DIV_NOT_FOUND, [idOrElt]);
                return null;
            }
            // PROFILING // this.$stopMeasure(msr1);
            return domElt;
        }
function ( idOrElt , newHTML ) { // PROFILING // var msr1 = this.$startMeasure("ReplaceHTML"); var domElt = idOrElt ; if ( typeof ( domElt ) == "string" ) { domElt = this . getElementById ( domElt ) ; } if ( domElt ) { if ( ( ariaCoreBrowser . isIE7 || ariaCoreBrowser . isIE8 ) && aria . utils && aria . utils . Delegate ) { try { var activeElement = Aria . $window . document . activeElement ; if ( activeElement && this . isAncestor ( activeElement , domElt ) ) { // On IE 7-8, there is an issue after removing from the DOM a focused element. // We detect it here so that next time there is a need to focus an element, we focus the // body first (which is the work-around for IE 7-8) aria . utils . Delegate . ieRemovingFocusedElement ( ) ; } } catch ( e ) { // on (real) IE8, an "Unspecified error" can be raised when trying to read // Aria.$window.document.activeElement // It happens when executing the following test: test.aria.utils.cfgframe.AriaWindowTest // It does not happen with IE 11 in IE8 mode. } } // PROFILING // var msr2 = this.$startMeasure("RemoveHTML"); // TODO: check HTML for security (no script ...) try { domElt . innerHTML = "" ; // this makes IE run faster (!) // PROFILING // this.$stopMeasure(msr2); domElt . innerHTML = newHTML ; } catch ( ex ) { // PTR 04429212: // IE does not support setting the innerHTML property of tbody, tfoot, thead or tr elements // directly. We use a simple work-around: // create a complete table, get the HTML element and insert it in the DOM var newDomElt = this . _createTableElement ( domElt . tagName , newHTML , domElt . ownerDocument ) ; if ( newDomElt ) { this . replaceDomElement ( domElt , newDomElt ) ; this . copyAttributes ( domElt , newDomElt ) ; domElt = newDomElt ; } else { // propagate the exception throw ex ; } } // PROFILING // var msr3 = this.$startMeasure("contentchange"); // use the delegate manager to forward a fake event if ( aria . utils && aria . utils . Delegate ) { aria . utils . Delegate . delegate ( aria . DomEvent . getFakeEvent ( 'contentchange' , domElt ) ) ; } // PROFILING // this.$stopMeasure(msr3); } else { this . $logError ( this . DIV_NOT_FOUND , [ idOrElt ] ) ; return null ; } // PROFILING // this.$stopMeasure(msr1); return domElt ; }
Replace the HTML contained in an element by another piece of HTML.
@param {aria.templates.CfgBeans:Div} idOrElt div whose content have to be replaced
@param {String} newHTML html to set
@return {Object} Reference to the html element, or null if the element was not found in the DOM. If the
element was not found in the DOM, the DIV_NOT_FOUND error is also logged. Note that in IE, in tables, the
returned domElt can be different from the one given as a parameter.
Replace the HTML contained in an element by another piece of HTML .