title: How to recursively select all children under an element Javascript
body: <p>I need a function that recursively selects all child elements but wont select elements (and those elements children) if they have the "foo" attribute.</p>
  
  <pre><code>&lt;section&gt;
    &lt;div&gt;
     &lt;span foo&gt;
      &lt;input&gt;
     &lt;/span&gt;
    &lt;/div&gt;
    &lt;p&gt;
      &lt;img&gt;
    &lt;/p&gt;
  &lt;/section&gt;
  //should return [section, div, p, img]
  </code></pre>
  
  <p>I need raw Javascript please</p>
  
  <p>edit:
  I tried something like this:</p>
  
  <pre><code>$tag.querySelectorAll(":not([foo])")
  </code></pre>
  
  <p>but querySelectorAll(":not([foo])") will still return the children of the unselected element.</p>