title: Failed to execute 'observe' on 'MutationObserver': parameter 1 is not of type 'Node'
body: <p>I am creating a script for adding attributes for some elements. And I want it to work for the 
  dynamically added elements. I wanted to use Mutation Observe, but I got this error: 
  <code>Failed to execute 'observe' on 'MutationObserver': parameter 1 is not of type 'Node'.</code></p>
  
  <p>The code I use:</p>
  
  <pre class="lang-js prettyprint-override"><code>const langAdding = (tag) =&gt; {
      tag.setAttribute('lang', 'en-us');
  }
  
  const target = document
  
  const callback = (mutations, observer) =&gt; {
      mutations.forEach(mutation =&gt; {
          switch (mutation.type) {
              case 'childList':
                  for (const el of mutation.addedNodes) {
                      if (!el.hasAttribute("lang")) {
                          el = langAdding(el) 
                      } else if (el.firstElementChild) {
                          for (const child of el.getElementsByTagName('p')) {
                              child = langAdding(child);
                      }
                  }
                  break;
          }
      })
  }
  
  const observer = new MutationObserver(callback);
  
  observer.observe(target, {
      childList: true,
      attributes: true,
      characterData: true,
      subtree: true
  });
  </code></pre>
  
  <p>And I really don't know if I did everything right. Please help me if you find a mistake</p>