title: Why is onbeforeunload always showing a dialog
body: <p>I am trying to have my javascript pop a dialog if there is data that hasn't been written yet, but it is always showing the confirmation dialog, even if there is nothing to be written.</p>
  
  <p>I have reduced the problem to this minimal failing case:</p>
  
  <pre><code>window.addEventListener("beforeunload", (e) =&gt; {
      e.returnValue = null;
      return null;
  });
  </code></pre>
  
  <p>With this in my code, the windows always ask for confirmation (both Chrome and Firefox).  Changing the null's to undefined's doesn't change anything.</p>
  
  <p>Can someone please lend me a clue?</p>