title: Error: Failed to execute 'dispatchEvent' on 'EventTarget'
body: <p>Some time ago I experienced a problem where scrolling on touch devices didn't work anymore when my ExtJS 5 App was embedded in an IFrame (see <a href="https://stackoverflow.com/questions/31201013/scrolling-issues-with-extjs-5-app-inside-iframe">this thread</a>).</p>
  
  <p>I've solved this by overriding some stuff from the Ext framework (see <a href="https://stackoverflow.com/a/31406648/1273551">the solution</a>).</p>
  
  <p>One step of the solution was to dispatch a <code>touchmove</code> event to the document itself (the framework prevents default handling of this event):</p>
  
  <pre><code>// ...
  touchmove: function(e) {
      window.document.dispatchEvent(e.event);
  }
  // ...
  </code></pre>
  
  <p>Even though this solution basically works it has one flaw:
  Dispatching the event throws an unhandled <code>InvalidStateError</code> on every <code>touchmove</code> event which is obviously quite often:</p>
  
  <p><a href="https://i.stack.imgur.com/gjt6Z.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gjt6Z.png" alt="enter image description here"></a></p>
  
  <p>If I simply put a try/catch around the <code>dispatchEvent</code> statement, scrolling inside the IFrame on touch devices doesn't work anymore as if not calling it at all.</p>
  
  <p>How can I get rid of the error without breaking scrolling again?</p>
  
  <p>Testapp where scrolling works but many unhandled errors occur can be <a href="https://skaface.leo.uberspace.de/ScrollTest/Ext510_fixed/" rel="nofollow noreferrer">tested here</a>.</p>