Upgrade to ExtJS 4.0.1 - Released 05/18/2011
[extjs.git] / docs / source / DomHelper.html
index 5478c6f..212b991 100644 (file)
@@ -1,46 +1,61 @@
-<html>\r
-<head>\r
-  <title>The source code</title>\r
-    <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />\r
-    <script type="text/javascript" src="../resources/prettify/prettify.js"></script>\r
-</head>\r
-<body  onload="prettyPrint();">\r
-    <pre class="prettyprint lang-js"><div id="cls-Ext.DomHelper"></div>/**
- * @class Ext.DomHelper
- * <p>The DomHelper class provides a layer of abstraction from DOM and transparently supports creating
+<!DOCTYPE html>
+<html>
+<head>
+  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+  <title>The source code</title>
+  <link href="../prettify/prettify.css" type="text/css" rel="stylesheet" />
+  <script type="text/javascript" src="../prettify/prettify.js"></script>
+  <style type="text/css">
+    .highlight { display: block; background-color: #ddd; }
+  </style>
+  <script type="text/javascript">
+    function highlight() {
+      document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
+    }
+  </script>
+</head>
+<body onload="prettyPrint(); highlight();">
+  <pre class="prettyprint lang-js"><span id='Ext-core-DomHelper'>/**
+</span> * @class Ext.core.DomHelper
+ * &lt;p&gt;The DomHelper class provides a layer of abstraction from DOM and transparently supports creating
  * elements via DOM or using HTML fragments. It also has the ability to create HTML fragment templates
- * from your DOM building code.</p>
+ * from your DOM building code.&lt;/p&gt;
  *
- * <p><b><u>DomHelper element specification object</u></b></p>
- * <p>A specification object is used when creating elements. Attributes of this object
+ * &lt;p&gt;&lt;b&gt;&lt;u&gt;DomHelper element specification object&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;
+ * &lt;p&gt;A specification object is used when creating elements. Attributes of this object
  * are assumed to be element attributes, except for 4 special attributes:
- * <div class="mdetail-params"><ul>
- * <li><b><tt>tag</tt></b> : <div class="sub-desc">The tag name of the element</div></li>
- * <li><b><tt>children</tt></b> : or <tt>cn</tt><div class="sub-desc">An array of the
+ * &lt;div class=&quot;mdetail-params&quot;&gt;&lt;ul&gt;
+ * &lt;li&gt;&lt;b&gt;&lt;tt&gt;tag&lt;/tt&gt;&lt;/b&gt; : &lt;div class=&quot;sub-desc&quot;&gt;The tag name of the element&lt;/div&gt;&lt;/li&gt;
+ * &lt;li&gt;&lt;b&gt;&lt;tt&gt;children&lt;/tt&gt;&lt;/b&gt; : or &lt;tt&gt;cn&lt;/tt&gt;&lt;div class=&quot;sub-desc&quot;&gt;An array of the
  * same kind of element definition objects to be created and appended. These can be nested
- * as deep as you want.</div></li>
- * <li><b><tt>cls</tt></b> : <div class="sub-desc">The class attribute of the element.
- * This will end up being either the "class" attribute on a HTML fragment or className
- * for a DOM node, depending on whether DomHelper is using fragments or DOM.</div></li>
- * <li><b><tt>html</tt></b> : <div class="sub-desc">The innerHTML for the element</div></li>
- * </ul></div></p>
+ * as deep as you want.&lt;/div&gt;&lt;/li&gt;
+ * &lt;li&gt;&lt;b&gt;&lt;tt&gt;cls&lt;/tt&gt;&lt;/b&gt; : &lt;div class=&quot;sub-desc&quot;&gt;The class attribute of the element.
+ * This will end up being either the &quot;class&quot; attribute on a HTML fragment or className
+ * for a DOM node, depending on whether DomHelper is using fragments or DOM.&lt;/div&gt;&lt;/li&gt;
+ * &lt;li&gt;&lt;b&gt;&lt;tt&gt;html&lt;/tt&gt;&lt;/b&gt; : &lt;div class=&quot;sub-desc&quot;&gt;The innerHTML for the element&lt;/div&gt;&lt;/li&gt;
+ * &lt;/ul&gt;&lt;/div&gt;&lt;/p&gt;
+ * &lt;p&gt;&lt;b&gt;NOTE:&lt;/b&gt; For other arbitrary attributes, the value will currently &lt;b&gt;not&lt;/b&gt; be automatically
+ * HTML-escaped prior to building the element's HTML string. This means that if your attribute value
+ * contains special characters that would not normally be allowed in a double-quoted attribute value,
+ * you &lt;b&gt;must&lt;/b&gt; manually HTML-encode it beforehand (see {@link Ext.String#htmlEncode}) or risk
+ * malformed HTML being created. This behavior may change in a future release.&lt;/p&gt;
  *
- * <p><b><u>Insertion methods</u></b></p>
- * <p>Commonly used insertion methods:
- * <div class="mdetail-params"><ul>
- * <li><b><tt>{@link #append}</tt></b> : <div class="sub-desc"></div></li>
- * <li><b><tt>{@link #insertBefore}</tt></b> : <div class="sub-desc"></div></li>
- * <li><b><tt>{@link #insertAfter}</tt></b> : <div class="sub-desc"></div></li>
- * <li><b><tt>{@link #overwrite}</tt></b> : <div class="sub-desc"></div></li>
- * <li><b><tt>{@link #createTemplate}</tt></b> : <div class="sub-desc"></div></li>
- * <li><b><tt>{@link #insertHtml}</tt></b> : <div class="sub-desc"></div></li>
- * </ul></div></p>
+ * &lt;p&gt;&lt;b&gt;&lt;u&gt;Insertion methods&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;
+ * &lt;p&gt;Commonly used insertion methods:
+ * &lt;div class=&quot;mdetail-params&quot;&gt;&lt;ul&gt;
+ * &lt;li&gt;&lt;b&gt;&lt;tt&gt;{@link #append}&lt;/tt&gt;&lt;/b&gt; : &lt;div class=&quot;sub-desc&quot;&gt;&lt;/div&gt;&lt;/li&gt;
+ * &lt;li&gt;&lt;b&gt;&lt;tt&gt;{@link #insertBefore}&lt;/tt&gt;&lt;/b&gt; : &lt;div class=&quot;sub-desc&quot;&gt;&lt;/div&gt;&lt;/li&gt;
+ * &lt;li&gt;&lt;b&gt;&lt;tt&gt;{@link #insertAfter}&lt;/tt&gt;&lt;/b&gt; : &lt;div class=&quot;sub-desc&quot;&gt;&lt;/div&gt;&lt;/li&gt;
+ * &lt;li&gt;&lt;b&gt;&lt;tt&gt;{@link #overwrite}&lt;/tt&gt;&lt;/b&gt; : &lt;div class=&quot;sub-desc&quot;&gt;&lt;/div&gt;&lt;/li&gt;
+ * &lt;li&gt;&lt;b&gt;&lt;tt&gt;{@link #createTemplate}&lt;/tt&gt;&lt;/b&gt; : &lt;div class=&quot;sub-desc&quot;&gt;&lt;/div&gt;&lt;/li&gt;
+ * &lt;li&gt;&lt;b&gt;&lt;tt&gt;{@link #insertHtml}&lt;/tt&gt;&lt;/b&gt; : &lt;div class=&quot;sub-desc&quot;&gt;&lt;/div&gt;&lt;/li&gt;
+ * &lt;/ul&gt;&lt;/div&gt;&lt;/p&gt;
  *
- * <p><b><u>Example</u></b></p>
- * <p>This is an example, where an unordered list with 3 children items is appended to an existing
- * element with id <tt>'my-div'</tt>:<br>
- <pre><code>
-var dh = Ext.DomHelper; // create shorthand alias
+ * &lt;p&gt;&lt;b&gt;&lt;u&gt;Example&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;
+ * &lt;p&gt;This is an example, where an unordered list with 3 children items is appended to an existing
+ * element with id &lt;tt&gt;'my-div'&lt;/tt&gt;:&lt;br&gt;
+ &lt;pre&gt;&lt;code&gt;
+var dh = Ext.core.DomHelper; // create shorthand alias
 // specification object
 var spec = {
     id: 'my-ul',
@@ -57,147 +72,211 @@ var list = dh.append(
     'my-div', // the context element 'my-div' can either be the id or the actual node
     spec      // the specification object
 );
- </code></pre></p>
- * <p>Element creation specification parameters in this class may also be passed as an Array of
+ &lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;
+ * &lt;p&gt;Element creation specification parameters in this class may also be passed as an Array of
  * specification objects. This can be used to insert multiple sibling nodes into an existing
- * container very efficiently. For example, to add more list items to the example above:<pre><code>
+ * container very efficiently. For example, to add more list items to the example above:&lt;pre&gt;&lt;code&gt;
 dh.append('my-ul', [
     {tag: 'li', id: 'item3', html: 'List Item 3'},
     {tag: 'li', id: 'item4', html: 'List Item 4'}
 ]);
- * </code></pre></p>
+ * &lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;
  *
- * <p><b><u>Templating</u></b></p>
- * <p>The real power is in the built-in templating. Instead of creating or appending any elements,
- * <tt>{@link #createTemplate}</tt> returns a Template object which can be used over and over to
+ * &lt;p&gt;&lt;b&gt;&lt;u&gt;Templating&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;
+ * &lt;p&gt;The real power is in the built-in templating. Instead of creating or appending any elements,
+ * &lt;tt&gt;{@link #createTemplate}&lt;/tt&gt; returns a Template object which can be used over and over to
  * insert new elements. Revisiting the example above, we could utilize templating this time:
- * <pre><code>
+ * &lt;pre&gt;&lt;code&gt;
 // create the node
 var list = dh.append('my-div', {tag: 'ul', cls: 'my-list'});
 // get template
 var tpl = dh.createTemplate({tag: 'li', id: 'item{0}', html: 'List Item {0}'});
 
-for(var i = 0; i < 5, i++){
+for(var i = 0; i &lt; 5, i++){
     tpl.append(list, [i]); // use template to append to the actual node
 }
- * </code></pre></p>
- * <p>An example using a template:<pre><code>
-var html = '<a id="{0}" href="{1}" class="nav">{2}</a>';
+ * &lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;
+ * &lt;p&gt;An example using a template:&lt;pre&gt;&lt;code&gt;
+var html = '&lt;a id=&quot;{0}&quot; href=&quot;{1}&quot; class=&quot;nav&quot;&gt;{2}&lt;/a&gt;';
 
-var tpl = new Ext.DomHelper.createTemplate(html);
-tpl.append('blog-roll', ['link1', 'http://www.jackslocum.com/', "Jack&#39;s Site"]);
-tpl.append('blog-roll', ['link2', 'http://www.dustindiaz.com/', "Dustin&#39;s Site"]);
- * </code></pre></p>
+var tpl = new Ext.core.DomHelper.createTemplate(html);
+tpl.append('blog-roll', ['link1', 'http://www.edspencer.net/', &quot;Ed&amp;#39;s Site&quot;]);
+tpl.append('blog-roll', ['link2', 'http://www.dustindiaz.com/', &quot;Dustin&amp;#39;s Site&quot;]);
+ * &lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;
  *
- * <p>The same example using named parameters:<pre><code>
-var html = '<a id="{id}" href="{url}" class="nav">{text}</a>';
+ * &lt;p&gt;The same example using named parameters:&lt;pre&gt;&lt;code&gt;
+var html = '&lt;a id=&quot;{id}&quot; href=&quot;{url}&quot; class=&quot;nav&quot;&gt;{text}&lt;/a&gt;';
 
-var tpl = new Ext.DomHelper.createTemplate(html);
+var tpl = new Ext.core.DomHelper.createTemplate(html);
 tpl.append('blog-roll', {
     id: 'link1',
-    url: 'http://www.jackslocum.com/',
-    text: "Jack&#39;s Site"
+    url: 'http://www.edspencer.net/',
+    text: &quot;Ed&amp;#39;s Site&quot;
 });
 tpl.append('blog-roll', {
     id: 'link2',
     url: 'http://www.dustindiaz.com/',
-    text: "Dustin&#39;s Site"
+    text: &quot;Dustin&amp;#39;s Site&quot;
 });
- * </code></pre></p>
+ * &lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;
  *
- * <p><b><u>Compiling Templates</u></b></p>
- * <p>Templates are applied using regular expressions. The performance is great, but if
+ * &lt;p&gt;&lt;b&gt;&lt;u&gt;Compiling Templates&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;
+ * &lt;p&gt;Templates are applied using regular expressions. The performance is great, but if
  * you are adding a bunch of DOM elements using the same template, you can increase
- * performance even further by {@link Ext.Template#compile "compiling"} the template.
- * The way "{@link Ext.Template#compile compile()}" works is the template is parsed and
+ * performance even further by {@link Ext.Template#compile &quot;compiling&quot;} the template.
+ * The way &quot;{@link Ext.Template#compile compile()}&quot; works is the template is parsed and
  * broken up at the different variable points and a dynamic function is created and eval'ed.
  * The generated function performs string concatenation of these parts and the passed
  * variables instead of using regular expressions.
- * <pre><code>
-var html = '<a id="{id}" href="{url}" class="nav">{text}</a>';
+ * &lt;pre&gt;&lt;code&gt;
+var html = '&lt;a id=&quot;{id}&quot; href=&quot;{url}&quot; class=&quot;nav&quot;&gt;{text}&lt;/a&gt;';
 
-var tpl = new Ext.DomHelper.createTemplate(html);
+var tpl = new Ext.core.DomHelper.createTemplate(html);
 tpl.compile();
 
 //... use template like normal
- * </code></pre></p>
+ * &lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;
  *
- * <p><b><u>Performance Boost</u></b></p>
- * <p>DomHelper will transparently create HTML fragments when it can. Using HTML fragments instead
- * of DOM can significantly boost performance.</p>
- * <p>Element creation specification parameters may also be strings. If {@link #useDom} is <tt>false</tt>,
- * then the string is used as innerHTML. If {@link #useDom} is <tt>true</tt>, a string specification
- * results in the creation of a text node. Usage:</p>
- * <pre><code>
-Ext.DomHelper.useDom = true; // force it to use DOM; reduces performance
- * </code></pre>
+ * &lt;p&gt;&lt;b&gt;&lt;u&gt;Performance Boost&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;
+ * &lt;p&gt;DomHelper will transparently create HTML fragments when it can. Using HTML fragments instead
+ * of DOM can significantly boost performance.&lt;/p&gt;
+ * &lt;p&gt;Element creation specification parameters may also be strings. If {@link #useDom} is &lt;tt&gt;false&lt;/tt&gt;,
+ * then the string is used as innerHTML. If {@link #useDom} is &lt;tt&gt;true&lt;/tt&gt;, a string specification
+ * results in the creation of a text node. Usage:&lt;/p&gt;
+ * &lt;pre&gt;&lt;code&gt;
+Ext.core.DomHelper.useDom = true; // force it to use DOM; reduces performance
+ * &lt;/code&gt;&lt;/pre&gt;
  * @singleton
  */
-Ext.DomHelper = function(){
+Ext.ns('Ext.core');
+Ext.core.DomHelper = function(){
     var tempTableEl = null,
-       emptyTags = /^(?:br|frame|hr|img|input|link|meta|range|spacer|wbr|area|param|col)$/i,
-       tableRe = /^table|tbody|tr|td$/i,
-       pub,
-       // kill repeat to save bytes
-       afterbegin = "afterbegin",
-       afterend = "afterend",
-       beforebegin = "beforebegin",
-       beforeend = "beforeend",
-       ts = '<table>',
-        te = '</table>',
-        tbs = ts+'<tbody>',
-        tbe = '</tbody>'+te,
-        trs = tbs + '<tr>',
-        tre = '</tr>'+tbe;
+        emptyTags = /^(?:br|frame|hr|img|input|link|meta|range|spacer|wbr|area|param|col)$/i,
+        tableRe = /^table|tbody|tr|td$/i,
+        confRe = /tag|children|cn|html$/i,
+        tableElRe = /td|tr|tbody/i,
+        endRe = /end/i,
+        pub,
+        // kill repeat to save bytes
+        afterbegin = 'afterbegin',
+        afterend = 'afterend',
+        beforebegin = 'beforebegin',
+        beforeend = 'beforeend',
+        ts = '&lt;table&gt;',
+        te = '&lt;/table&gt;',
+        tbs = ts+'&lt;tbody&gt;',
+        tbe = '&lt;/tbody&gt;'+te,
+        trs = tbs + '&lt;tr&gt;',
+        tre = '&lt;/tr&gt;'+tbe;
 
     // private
     function doInsert(el, o, returnElement, pos, sibling, append){
-        var newNode = pub.insertHtml(pos, Ext.getDom(el), createHtml(o));
+        el = Ext.getDom(el);
+        var newNode;
+        if (pub.useDom) {
+            newNode = createDom(o, null);
+            if (append) {
+                el.appendChild(newNode);
+            } else {
+                (sibling == 'firstChild' ? el : el.parentNode).insertBefore(newNode, el[sibling] || el);
+            }
+        } else {
+            newNode = Ext.core.DomHelper.insertHtml(pos, el, Ext.core.DomHelper.createHtml(o));
+        }
         return returnElement ? Ext.get(newNode, true) : newNode;
     }
+    
+    function createDom(o, parentNode){
+        var el,
+            doc = document,
+            useSet,
+            attr,
+            val,
+            cn;
+
+        if (Ext.isArray(o)) {                       // Allow Arrays of siblings to be inserted
+            el = doc.createDocumentFragment(); // in one shot using a DocumentFragment
+            for (var i = 0, l = o.length; i &lt; l; i++) {
+                createDom(o[i], el);
+            }
+        } else if (typeof o == 'string') {         // Allow a string as a child spec.
+            el = doc.createTextNode(o);
+        } else {
+            el = doc.createElement( o.tag || 'div' );
+            useSet = !!el.setAttribute; // In IE some elements don't have setAttribute
+            for (attr in o) {
+                if(!confRe.test(attr)){
+                    val = o[attr];
+                    if(attr == 'cls'){
+                        el.className = val;
+                    }else{
+                        if(useSet){
+                            el.setAttribute(attr, val);
+                        }else{
+                            el[attr] = val;
+                        }
+                    }
+                }
+            }
+            Ext.core.DomHelper.applyStyles(el, o.style);
+
+            if ((cn = o.children || o.cn)) {
+                createDom(cn, el);
+            } else if (o.html) {
+                el.innerHTML = o.html;
+            }
+        }
+        if(parentNode){
+           parentNode.appendChild(el);
+        }
+        return el;
+    }
 
     // build as innerHTML where available
     function createHtml(o){
-           var b = "",
-               attr,
-               val,
-               key,
-               keyVal,
-               cn;
+        var b = '',
+            attr,
+            val,
+            key,
+            cn,
+            i;
 
-        if(typeof o == 'string'){
+        if(typeof o == &quot;string&quot;){
             b = o;
         } else if (Ext.isArray(o)) {
-               Ext.each(o, function(v) {
-                b += createHtml(v);
-            });
+            for (i=0; i &lt; o.length; i++) {
+                if(o[i]) {
+                    b += createHtml(o[i]);
+                }
+            }
         } else {
-               b += "<" + (o.tag = o.tag || "div");
-            Ext.iterate(o, function(attr, val){
-                if(!/tag|children|cn|html$/i.test(attr)){
-                    if (Ext.isObject(val)) {
-                        b += " " + attr + "='";
-                        Ext.iterate(val, function(key, keyVal){
-                            b += key + ":" + keyVal + ";";
-                        });
-                        b += "'";
+            b += '&lt;' + (o.tag = o.tag || 'div');
+            for (attr in o) {
+                val = o[attr];
+                if(!confRe.test(attr)){
+                    if (typeof val == &quot;object&quot;) {
+                        b += ' ' + attr + '=&quot;';
+                        for (key in val) {
+                            b += key + ':' + val[key] + ';';
+                        }
+                        b += '&quot;';
                     }else{
-                        b += " " + ({cls : "class", htmlFor : "for"}[attr] || attr) + "='" + val + "'";
+                        b += ' ' + ({cls : 'class', htmlFor : 'for'}[attr] || attr) + '=&quot;' + val + '&quot;';
                     }
                 }
-            });
-               // Now either just close the tag or try to add children and close the tag.
-               if (emptyTags.test(o.tag)) {
-                   b += "/>";
-               } else {
-                   b += ">";
-                   if ((cn = o.children || o.cn)) {
-                       b += createHtml(cn);
-                   } else if(o.html){
-                       b += o.html;
-                   }
-                   b += "</" + o.tag + ">";
-               }
+            }
+            // Now either just close the tag or try to add children and close the tag.
+            if (emptyTags.test(o.tag)) {
+                b += '/&gt;';
+            } else {
+                b += '&gt;';
+                if ((cn = o.children || o.cn)) {
+                    b += createHtml(cn);
+                } else if(o.html){
+                    b += o.html;
+                }
+                b += '&lt;/' + o.tag + '&gt;';
+            }
         }
         return b;
     }
@@ -205,177 +284,277 @@ Ext.DomHelper = function(){
     function ieTable(depth, s, h, e){
         tempTableEl.innerHTML = [s, h, e].join('');
         var i = -1,
-               el = tempTableEl;
-        while(++i < depth){
+            el = tempTableEl,
+            ns;
+        while(++i &lt; depth){
             el = el.firstChild;
         }
+//      If the result is multiple siblings, then encapsulate them into one fragment.
+        ns = el.nextSibling;
+        if (ns){
+            var df = document.createDocumentFragment();
+            while(el){
+                ns = el.nextSibling;
+                df.appendChild(el);
+                el = ns;
+            }
+            el = df;
+        }
         return el;
     }
 
-    /**
-     * @ignore
+<span id='Ext-core-DomHelper-method-insertIntoTable'>    /**
+</span>     * @ignore
      * Nasty code for IE's broken table implementation
      */
     function insertIntoTable(tag, where, el, html) {
-           var node,
-               before;
+        var node,
+            before;
 
         tempTableEl = tempTableEl || document.createElement('div');
 
-           if(tag == 'td' && (where == afterbegin || where == beforeend) ||
-              !/td|tr|tbody/i.test(tag) && (where == beforebegin || where == afterend)) {
-            return;
+        if(tag == 'td' &amp;&amp; (where == afterbegin || where == beforeend) ||
+           !tableElRe.test(tag) &amp;&amp; (where == beforebegin || where == afterend)) {
+            return null;
         }
         before = where == beforebegin ? el :
-                                where == afterend ? el.nextSibling :
-                                where == afterbegin ? el.firstChild : null;
+                 where == afterend ? el.nextSibling :
+                 where == afterbegin ? el.firstChild : null;
 
         if (where == beforebegin || where == afterend) {
-               el = el.parentNode;
-       }
+            el = el.parentNode;
+        }
 
-        if (tag == 'td' || (tag == "tr" && (where == beforeend || where == afterbegin))) {
-               node = ieTable(4, trs, html, tre);
-        } else if ((tag == "tbody" && (where == beforeend || where == afterbegin)) ||
-                          (tag == "tr" && (where == beforebegin || where == afterend))) {
-               node = ieTable(3, tbs, html, tbe);
+        if (tag == 'td' || (tag == 'tr' &amp;&amp; (where == beforeend || where == afterbegin))) {
+            node = ieTable(4, trs, html, tre);
+        } else if ((tag == 'tbody' &amp;&amp; (where == beforeend || where == afterbegin)) ||
+                   (tag == 'tr' &amp;&amp; (where == beforebegin || where == afterend))) {
+            node = ieTable(3, tbs, html, tbe);
         } else {
-               node = ieTable(2, ts, html, te);
+            node = ieTable(2, ts, html, te);
         }
         el.insertBefore(node, before);
         return node;
     }
+    
+<span id='Ext-core-DomHelper-method-createContextualFragment'>    /**
+</span>     * @ignore
+     * Fix for IE9 createContextualFragment missing method
+     */   
+    function createContextualFragment(html){
+        var div = document.createElement(&quot;div&quot;),
+            fragment = document.createDocumentFragment(),
+            i = 0,
+            length, childNodes;
+        
+        div.innerHTML = html;
+        childNodes = div.childNodes;
+        length = childNodes.length;
 
+        for (; i &lt; length; i++) {
+            fragment.appendChild(childNodes[i].cloneNode(true));
+        }
 
+        return fragment;
+    }
+    
     pub = {
-           <div id="method-Ext.DomHelper-markup"></div>/**
-            * Returns the markup for the passed Element(s) config.
-            * @param {Object} o The DOM object spec (and children)
-            * @return {String}
-            */
-           markup : function(o){
-               return createHtml(o);
-           },
+<span id='Ext-core-DomHelper-method-markup'>        /**
+</span>         * Returns the markup for the passed Element(s) config.
+         * @param {Object} o The DOM object spec (and children)
+         * @return {String}
+         */
+        markup : function(o){
+            return createHtml(o);
+        },
 
-           <div id="method-Ext.DomHelper-insertHtml"></div>/**
-            * Inserts an HTML fragment into the DOM.
-            * @param {String} where Where to insert the html in relation to el - beforeBegin, afterBegin, beforeEnd, afterEnd.
-            * @param {HTMLElement} el The context element
-            * @param {String} html The HTML fragmenet
-            * @return {HTMLElement} The new node
-            */
-           insertHtml : function(where, el, html){
-               var hash = {},
-                       hashVal,
-                       setStart,
-                       range,
-                       frag,
-                       rangeEl,
-                       rs;
+<span id='Ext-core-DomHelper-method-applyStyles'>        /**
+</span>         * Applies a style specification to an element.
+         * @param {String/HTMLElement} el The element to apply styles to
+         * @param {String/Object/Function} styles A style specification string e.g. 'width:100px', or object in the form {width:'100px'}, or
+         * a function which returns such a specification.
+         */
+        applyStyles : function(el, styles){
+            if (styles) {
+                el = Ext.fly(el);
+                if (typeof styles == &quot;function&quot;) {
+                    styles = styles.call();
+                }
+                if (typeof styles == &quot;string&quot;) {
+                    styles = Ext.core.Element.parseStyles(styles);
+                }
+                if (typeof styles == &quot;object&quot;) {
+                    el.setStyle(styles);
+                }
+            }
+        },
 
-               where = where.toLowerCase();
-               // add these here because they are used in both branches of the condition.
-               hash[beforebegin] = ['BeforeBegin', 'previousSibling'];
-               hash[afterend] = ['AfterEnd', 'nextSibling'];
+<span id='Ext-core-DomHelper-method-insertHtml'>        /**
+</span>         * Inserts an HTML fragment into the DOM.
+         * @param {String} where Where to insert the html in relation to el - beforeBegin, afterBegin, beforeEnd, afterEnd.
+         * @param {HTMLElement/TextNode} el The context element
+         * @param {String} html The HTML fragment
+         * @return {HTMLElement} The new node
+         */
+        insertHtml : function(where, el, html){
+            var hash = {},
+                hashVal,
+                range,
+                rangeEl,
+                setStart,
+                frag,
+                rs;
 
-               if (el.insertAdjacentHTML) {
-                   if(tableRe.test(el.tagName) && (rs = insertIntoTable(el.tagName.toLowerCase(), where, el, html))){
-                       return rs;
-                   }
-                   // add these two to the hash.
-                   hash[afterbegin] = ['AfterBegin', 'firstChild'];
-                   hash[beforeend] = ['BeforeEnd', 'lastChild'];
-                   if ((hashVal = hash[where])) {
-                               el.insertAdjacentHTML(hashVal[0], html);
-                       return el[hashVal[1]];
-                   }
-               } else {
-                       range = el.ownerDocument.createRange();
-                       setStart = "setStart" + (/end/i.test(where) ? "After" : "Before");
-                       if (hash[where]) {
-                               range[setStart](el);
-                               frag = range.createContextualFragment(html);
-                               el.parentNode.insertBefore(frag, where == beforebegin ? el : el.nextSibling);
-                               return el[(where == beforebegin ? "previous" : "next") + "Sibling"];
-                       } else {
-                               rangeEl = (where == afterbegin ? "first" : "last") + "Child";
-                               if (el.firstChild) {
-                                       range[setStart](el[rangeEl]);
-                                       frag = range.createContextualFragment(html);
+            where = where.toLowerCase();
+            // add these here because they are used in both branches of the condition.
+            hash[beforebegin] = ['BeforeBegin', 'previousSibling'];
+            hash[afterend] = ['AfterEnd', 'nextSibling'];
+            
+            // if IE and context element is an HTMLElement
+            if (el.insertAdjacentHTML) {
+                if(tableRe.test(el.tagName) &amp;&amp; (rs = insertIntoTable(el.tagName.toLowerCase(), where, el, html))){
+                    return rs;
+                }
+                
+                // add these two to the hash.
+                hash[afterbegin] = ['AfterBegin', 'firstChild'];
+                hash[beforeend] = ['BeforeEnd', 'lastChild'];
+                if ((hashVal = hash[where])) {
+                    el.insertAdjacentHTML(hashVal[0], html);
+                    return el[hashVal[1]];
+                }
+            // if (not IE and context element is an HTMLElement) or TextNode
+            } else {
+                // we cannot insert anything inside a textnode so...
+                if (Ext.isTextNode(el)) {
+                    where = where === 'afterbegin' ? 'beforebegin' : where; 
+                    where = where === 'beforeend' ? 'afterend' : where;
+                }
+                range = Ext.supports.CreateContextualFragment ? el.ownerDocument.createRange() : undefined;
+                setStart = 'setStart' + (endRe.test(where) ? 'After' : 'Before');
+                if (hash[where]) {
+                    if (range) {
+                        range[setStart](el);
+                        frag = range.createContextualFragment(html);
+                    } else {
+                        frag = createContextualFragment(html);
+                    }
+                    el.parentNode.insertBefore(frag, where == beforebegin ? el : el.nextSibling);
+                    return el[(where == beforebegin ? 'previous' : 'next') + 'Sibling'];
+                } else {
+                    rangeEl = (where == afterbegin ? 'first' : 'last') + 'Child';
+                    if (el.firstChild) {
+                        if (range) {
+                            range[setStart](el[rangeEl]);
+                            frag = range.createContextualFragment(html);
+                        } else {
+                            frag = createContextualFragment(html);
+                        }
+                        
                         if(where == afterbegin){
                             el.insertBefore(frag, el.firstChild);
                         }else{
                             el.appendChild(frag);
                         }
-                               } else {
-                                   el.innerHTML = html;
-                           }
-                           return el[rangeEl];
-                       }
-               }
-               throw 'Illegal insertion point -> "' + where + '"';
-           },
+                    } else {
+                        el.innerHTML = html;
+                    }
+                    return el[rangeEl];
+                }
+            }
+            //&lt;debug&gt;
+            Ext.Error.raise({
+                sourceClass: 'Ext.core.DomHelper',
+                sourceMethod: 'insertHtml',
+                htmlToInsert: html,
+                targetElement: el,
+                msg: 'Illegal insertion point reached: &quot;' + where + '&quot;'
+            });
+            //&lt;/debug&gt;
+        },
 
-           <div id="method-Ext.DomHelper-insertBefore"></div>/**
-            * Creates new DOM element(s) and inserts them before el.
-            * @param {Mixed} el The context element
-            * @param {Object/String} o The DOM object spec (and children) or raw HTML blob
-            * @param {Boolean} returnElement (optional) true to return a Ext.Element
-            * @return {HTMLElement/Ext.Element} The new node
-            */
-           insertBefore : function(el, o, returnElement){
-               return doInsert(el, o, returnElement, beforebegin);
-           },
+<span id='Ext-core-DomHelper-method-insertBefore'>        /**
+</span>         * Creates new DOM element(s) and inserts them before el.
+         * @param {Mixed} el The context element
+         * @param {Object/String} o The DOM object spec (and children) or raw HTML blob
+         * @param {Boolean} returnElement (optional) true to return a Ext.core.Element
+         * @return {HTMLElement/Ext.core.Element} The new node
+         */
+        insertBefore : function(el, o, returnElement){
+            return doInsert(el, o, returnElement, beforebegin);
+        },
 
-           <div id="method-Ext.DomHelper-insertAfter"></div>/**
-            * Creates new DOM element(s) and inserts them after el.
-            * @param {Mixed} el The context element
-            * @param {Object} o The DOM object spec (and children)
-            * @param {Boolean} returnElement (optional) true to return a Ext.Element
-            * @return {HTMLElement/Ext.Element} The new node
-            */
-           insertAfter : function(el, o, returnElement){
-               return doInsert(el, o, returnElement, afterend, "nextSibling");
-           },
+<span id='Ext-core-DomHelper-method-insertAfter'>        /**
+</span>         * Creates new DOM element(s) and inserts them after el.
+         * @param {Mixed} el The context element
+         * @param {Object} o The DOM object spec (and children)
+         * @param {Boolean} returnElement (optional) true to return a Ext.core.Element
+         * @return {HTMLElement/Ext.core.Element} The new node
+         */
+        insertAfter : function(el, o, returnElement){
+            return doInsert(el, o, returnElement, afterend, 'nextSibling');
+        },
 
-           <div id="method-Ext.DomHelper-insertFirst"></div>/**
-            * Creates new DOM element(s) and inserts them as the first child of el.
-            * @param {Mixed} el The context element
-            * @param {Object/String} o The DOM object spec (and children) or raw HTML blob
-            * @param {Boolean} returnElement (optional) true to return a Ext.Element
-            * @return {HTMLElement/Ext.Element} The new node
-            */
-           insertFirst : function(el, o, returnElement){
-               return doInsert(el, o, returnElement, afterbegin, "firstChild");
-           },
+<span id='Ext-core-DomHelper-method-insertFirst'>        /**
+</span>         * Creates new DOM element(s) and inserts them as the first child of el.
+         * @param {Mixed} el The context element
+         * @param {Object/String} o The DOM object spec (and children) or raw HTML blob
+         * @param {Boolean} returnElement (optional) true to return a Ext.core.Element
+         * @return {HTMLElement/Ext.core.Element} The new node
+         */
+        insertFirst : function(el, o, returnElement){
+            return doInsert(el, o, returnElement, afterbegin, 'firstChild');
+        },
 
-           <div id="method-Ext.DomHelper-append"></div>/**
-            * Creates new DOM element(s) and appends them to el.
-            * @param {Mixed} el The context element
-            * @param {Object/String} o The DOM object spec (and children) or raw HTML blob
-            * @param {Boolean} returnElement (optional) true to return a Ext.Element
-            * @return {HTMLElement/Ext.Element} The new node
-            */
-           append : function(el, o, returnElement){
-                   return doInsert(el, o, returnElement, beforeend, "", true);
-           },
+<span id='Ext-core-DomHelper-method-append'>        /**
+</span>         * Creates new DOM element(s) and appends them to el.
+         * @param {Mixed} el The context element
+         * @param {Object/String} o The DOM object spec (and children) or raw HTML blob
+         * @param {Boolean} returnElement (optional) true to return a Ext.core.Element
+         * @return {HTMLElement/Ext.core.Element} The new node
+         */
+        append : function(el, o, returnElement){
+            return doInsert(el, o, returnElement, beforeend, '', true);
+        },
 
-           <div id="method-Ext.DomHelper-overwrite"></div>/**
-            * Creates new DOM element(s) and overwrites the contents of el with them.
-            * @param {Mixed} el The context element
-            * @param {Object/String} o The DOM object spec (and children) or raw HTML blob
-            * @param {Boolean} returnElement (optional) true to return a Ext.Element
-            * @return {HTMLElement/Ext.Element} The new node
-            */
-           overwrite : function(el, o, returnElement){
-               el = Ext.getDom(el);
-               el.innerHTML = createHtml(o);
-               return returnElement ? Ext.get(el.firstChild) : el.firstChild;
-           },
+<span id='Ext-core-DomHelper-method-overwrite'>        /**
+</span>         * Creates new DOM element(s) and overwrites the contents of el with them.
+         * @param {Mixed} el The context element
+         * @param {Object/String} o The DOM object spec (and children) or raw HTML blob
+         * @param {Boolean} returnElement (optional) true to return a Ext.core.Element
+         * @return {HTMLElement/Ext.core.Element} The new node
+         */
+        overwrite : function(el, o, returnElement){
+            el = Ext.getDom(el);
+            el.innerHTML = createHtml(o);
+            return returnElement ? Ext.get(el.firstChild) : el.firstChild;
+        },
 
-           createHtml : createHtml
+        createHtml : createHtml,
+        
+<span id='Ext-core-DomHelper-method-createDom'>        /**
+</span>         * Creates new DOM element(s) without inserting them to the document.
+         * @param {Object/String} o The DOM object spec (and children) or raw HTML blob
+         * @return {HTMLElement} The new uninserted node
+         * @method
+         */
+        createDom: createDom,
+        
+<span id='Ext-core-DomHelper-property-useDom'>        /** True to force the use of DOM instead of html fragments @type Boolean */
+</span>        useDom : false,
+        
+<span id='Ext-core-DomHelper-method-createTemplate'>        /**
+</span>         * Creates a new Ext.Template from the DOM object spec.
+         * @param {Object} o The DOM object spec (and children)
+         * @return {Ext.Template} The new template
+         */
+        createTemplate : function(o){
+            var html = Ext.core.DomHelper.createHtml(o);
+            return Ext.create('Ext.Template', html);
+        }
     };
     return pub;
-}();</pre>    \r
-</body>\r
-</html>
\ No newline at end of file
+}();
+</pre>
+</body>
+</html>