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.
FF20 good
IE9 some support (undo stack cleared when input loses focus)
Safari5 some support (undo stack cleared when input loses focus)
Chrome26 unreliable
For example, a script that trims spaces (see also jsfiddle below)
- type some spaces before "hello!",
- click outside the input element
- click on the input element and press Ctrl-Z
now the text is gone (in Chome)
jsfiddle here
<input type="text" id="input1" value="hello!">
document.getElementById("input1").addEventListener('blur', function(evt){elementLosesFocus(evt, this);}, false);
function elementLosesFocus(evt, caller)
{
caller.value = caller.value.trim();
}
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).