-
- delete Ext.elCache[me.id];
- Ext.removeNode(me.dom);
- me.id = Ext.id(me.dom = el);
- Ext.Element.addToCache(me.isFlyweight ? new Ext.Element(me.dom) : me);
- return me;
- },
-
- <div id="method-Ext.Element-createChild"></div>/**
- * Creates the passed DomHelper config and appends it to this element or optionally inserts it before the passed child element.
- * @param {Object} config DomHelper element config object. If no tag is specified (e.g., {tag:'input'}) then a div will be
- * automatically generated with the specified attributes.
- * @param {HTMLElement} insertBefore (optional) a child element of this element
- * @param {Boolean} returnDom (optional) true to return the dom node instead of creating an Element
- * @return {Ext.Element} The new child element
- */
- createChild: function(config, insertBefore, returnDom){
- config = config || {tag:'div'};
- return insertBefore ?
- DH.insertBefore(insertBefore, config, returnDom !== true) :
- DH[!this.dom.firstChild ? 'overwrite' : 'append'](this.dom, config, returnDom !== true);
- },
-
- <div id="method-Ext.Element-wrap"></div>/**
- * Creates and wraps this element with another element
- * @param {Object} config (optional) DomHelper element config object for the wrapper element or null for an empty div
- * @param {Boolean} returnDom (optional) True to return the raw DOM element instead of Ext.Element
- * @return {HTMLElement/Element} The newly created wrapper element
- */
- wrap: function(config, returnDom){
- var newEl = DH.insertBefore(this.dom, config || {tag: "div"}, !returnDom);
- newEl.dom ? newEl.dom.appendChild(this.dom) : newEl.appendChild(this.dom);
- return newEl;
- },
-
- <div id="method-Ext.Element-insertHtml"></div>/**
- * Inserts an html fragment into this element
- * @param {String} where Where to insert the html in relation to this element - beforeBegin, afterBegin, beforeEnd, afterEnd.
- * @param {String} html The HTML fragment
- * @param {Boolean} returnEl (optional) True to return an Ext.Element (defaults to false)
- * @return {HTMLElement/Ext.Element} The inserted node (or nearest related if more than 1 inserted)
- */
- insertHtml : function(where, html, returnEl){
- var el = DH.insertHtml(where, this.dom, html);
- return returnEl ? Ext.get(el) : el;
- }
- }
-}());</pre>
+ }
+ return rt;
+ },
+
+<span id='Ext-core-Element-method-replace'> /**
+</span> * Replaces the passed element with this element
+ * @param {Mixed} el The element to replace
+ * @return {Ext.core.Element} this
+ */
+ replace : function(el) {
+ el = Ext.get(el);
+ this.insertBefore(el);
+ el.remove();
+ return this;
+ },
+
+<span id='Ext-core-Element-method-replaceWith'> /**
+</span> * Replaces this element with the passed element
+ * @param {Mixed/Object} el The new element or a DomHelper config of an element to create
+ * @return {Ext.core.Element} this
+ */
+ replaceWith: function(el){
+ var me = this;
+
+ if(el.nodeType || el.dom || typeof el == 'string'){
+ el = Ext.get(el);
+ me.dom.parentNode.insertBefore(el, me.dom);
+ }else{
+ el = Ext.core.DomHelper.insertBefore(me.dom, el);
+ }
+
+ delete Ext.cache[me.id];
+ Ext.removeNode(me.dom);
+ me.id = Ext.id(me.dom = el);
+ Ext.core.Element.addToCache(me.isFlyweight ? new Ext.core.Element(me.dom) : me);
+ return me;
+ },
+
+<span id='Ext-core-Element-method-createChild'> /**
+</span> * Creates the passed DomHelper config and appends it to this element or optionally inserts it before the passed child element.
+ * @param {Object} config DomHelper element config object. If no tag is specified (e.g., {tag:'input'}) then a div will be
+ * automatically generated with the specified attributes.
+ * @param {HTMLElement} insertBefore (optional) a child element of this element
+ * @param {Boolean} returnDom (optional) true to return the dom node instead of creating an Element
+ * @return {Ext.core.Element} The new child element
+ */
+ createChild : function(config, insertBefore, returnDom) {
+ config = config || {tag:'div'};
+ if (insertBefore) {
+ return Ext.core.DomHelper.insertBefore(insertBefore, config, returnDom !== true);
+ }
+ else {
+ return Ext.core.DomHelper[!this.dom.firstChild ? 'insertFirst' : 'append'](this.dom, config, returnDom !== true);
+ }
+ },
+
+<span id='Ext-core-Element-method-wrap'> /**
+</span> * Creates and wraps this element with another element
+ * @param {Object} config (optional) DomHelper element config object for the wrapper element or null for an empty div
+ * @param {Boolean} returnDom (optional) True to return the raw DOM element instead of Ext.core.Element
+ * @return {HTMLElement/Element} The newly created wrapper element
+ */
+ wrap : function(config, returnDom) {
+ var newEl = Ext.core.DomHelper.insertBefore(this.dom, config || {tag: "div"}, !returnDom),
+ d = newEl.dom || newEl;
+
+ d.appendChild(this.dom);
+ return newEl;
+ },
+
+<span id='Ext-core-Element-method-insertHtml'> /**
+</span> * Inserts an html fragment into this element
+ * @param {String} where Where to insert the html in relation to this element - beforeBegin, afterBegin, beforeEnd, afterEnd.
+ * @param {String} html The HTML fragment
+ * @param {Boolean} returnEl (optional) True to return an Ext.core.Element (defaults to false)
+ * @return {HTMLElement/Ext.core.Element} The inserted node (or nearest related if more than 1 inserted)
+ */
+ insertHtml : function(where, html, returnEl) {
+ var el = Ext.core.DomHelper.insertHtml(where, this.dom, html);
+ return returnEl ? Ext.get(el) : el;
+ }
+});
+</pre>