title: The effect of using DOM method normalize()
body: <p>It seems that I do not understand the exact action of the DOM method <code>normalize()</code>.</p>
  
  <p>I thought that it removes entirely empty Text nodes. However I do not observe this effect.</p>
  
  <p>Here is a sample document.</p>
  
  <pre><code>&lt;!DOCTYPE html /&gt;
  
  &lt;html lang = "en"&gt;
  
  &lt;head&gt;
      &lt;meta charset = "Utf-8" /&gt;
      &lt;title&gt;Normalize&lt;/title&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  
      &lt;form accept = "#" method = "post"&gt;
          &lt;fieldset&gt;&lt;legend&gt;Using normalize()&lt;/legend&gt;
          &lt;p&gt;The form is used only to test the method normalize().&lt;/p&gt;
          &lt;div&gt;
              &lt;label for = "text"&gt;Label&lt;/label&gt;
              &lt;input type = "text" name = "text" id = "text"/&gt;
          &lt;/div&gt;
          &lt;/fieldset&gt;
      &lt;/form&gt;
  
      &lt;script&gt;
          window.onload = function () {
              var element = document.getElementById("text");
  
              do {
                  alert(element);
                  element = element.previousSibling;
              } while (element.nodeType != Node.ELEMENT_NODE);
  
              alert(element);
  
              var element = document.getElementById("text");
  
              element.parentNode.normalize();
  
              do {
                  alert(element);
                  element = element.previousSibling;
              } while (element.nodeType != Node.ELEMENT_NODE);
  
              alert(element);
          };
      &lt;/script&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>The first <code>do-while</code> outputs nodes when method <code>normalize()</code> was not yet called.
  Its output in <code>IE-11</code> is the following</p>
  
  <pre><code>[object HTMLInputElement]
  [object Text]
  [object HTMLLabelElement]
  </code></pre>
  
  <p>However after calling method <code>normalize()</code> the next <code>do-while</code> loop produces the same sequence of outputs:</p>
  
  <pre><code>[object HTMLInputElement]
  [object Text]
  [object HTMLLabelElement]
  </code></pre>
  
  <p>I thought that the output</p>
  
  <pre><code>[object Text]
  </code></pre>
  
  <p>should be absent in the second loop.</p>
  
  <p>What is wrong in my understanding of the method <code>normalize()</code>?
  Or what is the exact definition of the empty Text node in the DOM specification?</p>