title: Should a "script" tag be allowed to remove itself?
body: <p>We've been having a discussion at our workplace on this with some for and some against the behavior. Wanted to hear views from you guys : </p>
  
  <pre><code>&lt;html&gt;
  &lt;body&gt;
  &lt;div&gt;
  Test!
  &lt;script&gt; document.body.removeChild(document.getElementsByTagName('div')[0]); &lt;/script&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Should the above script work and do what it's supposed to do? First, let's see what's happening here : </p>
  
  <p>I have a javascript that's inside the <code>&lt;div&gt;</code> element. This javascript will delete the child node within body which happens to hold the div inside which the script itself exists.</p>
  
  <p>Now, the above script works fine in Firefox, Opera and IE8. But IE6 and IE7 give an alert saying they cannot open the page.</p>
  
  <p>Let's not debate on how IE should have handled this (they've accepted it as a bug and hence fixed it in IE8). The point here is since the <strong>'SCRIPT'</strong> tag itself is a part of DOM, should it be allowed to do something like this? Should it even exist after such an operation?</p>
  
  <p><strong><em>Edit</em></strong>: </p>
  
  <p>Firefox, Opera, IE9 etc. do not remove the 'script' tag if I run the above code. But, document.getElementsByTagName('script').length returns 0! </p>
  
  <p>To understand what I mean, add <code>alert(document.getElementsByTagName('script').length);</code> before and after <code>document.body.removeChild(document.getElementsByTagName('div')[0]);</code> in the code above.</p>