title: In Chrome undo does not work properly for input element after contents changed programmatically
body: <p>In Chrome, I noticed that undo does not work properly for input element after the contents of the element has been changed programmatically. Although I get different behaviours for different browsers, they're not as bad as Chrome.</p>
  
  <pre><code>FF20      good
  IE9       some support (undo stack cleared when input loses focus)
  Safari5   some support (undo stack cleared when input loses focus)
  Chrome26  unreliable
  </code></pre>
  
  <p>For example, a script that trims spaces (see also jsfiddle below)</p>
  
  <ul>
  <li>type some spaces before "hello!",</li>
  <li>click outside the input element</li>
  <li>click on the input element and press Ctrl-Z</li>
  </ul>
  
  <p>now the text is gone (in Chome)</p>
  
  <p><a href="http://jsfiddle.net/K75t7/" rel="noreferrer">jsfiddle here</a></p>
  
  <pre><code>&lt;input type="text" id="input1" value="hello!"&gt;
  
  document.getElementById("input1").addEventListener('blur', function(evt){elementLosesFocus(evt, this);}, false);
  
  function elementLosesFocus(evt, caller)
  {
      caller.value = caller.value.trim();
  }
  </code></pre>
  
  <p>I think the best thing I can hope for is a method to somehow clear the undo history of the input when it loses focus (as is the case with IE and Safari).</p>