I am coming to the conclusion after some investigation that undo/redo grouping (*) in, say, textareas, will be broken by any modification to the document.
1) Is this really the case? Is this 'spec' behavior? Exactly what breaks undo/redo grouping?
2) Is there any getting around it? For instance, marking the parts one wants to change as being non-data, non-model, i.e not part of the 'real state' (I suppose the idea here would be kind of like Shadow DOM).
(*) By Undo/Redo grouping, I mean the way that a bunch of characters typed in, or a number of backspace actions, can usually be undone or redone together.
This is useful to be able preserve nice undo/redo and at the same time provide feedback arbitrarily, for instance after every change to a textarea being edited.
EDIT: Found out that in Safari (rather old version, don't know about present version), this does not break, the undo/redo grouping works. The problem above was found testing in Chrome-78. So I guess it might not be a standards/spec thing.