[whatwg] Fixing undo on the Web - UndoManager and Transaction

Aryeh Gregor ayg at aryeh.name
Wed Sep 21 13:41:34 PDT 2011


On Wed, Sep 21, 2011 at 12:58 PM, Ryosuke Niwa <rniwa at webkit.org> wrote:
> So apply, unapply, and reapply are callback functions supplied by authors
> and called by UAs.
> e.g.
> myUndoScope.undoManager.transact({
>   apply: function() {alert('done');},
>   unapply: function() {alert('undone');},
>   reapply: function() {alert('redone');}
> })
>
> the above code inserts a new transaction which pops up alert('done'), and
> then alert('undo') and alert('redone') when the transaction is undone or
> redone.  But undo/redo of a transaction is done through undoManager.undo,
> undoManager.redo, or execCommand so authors don't ever call unapply or
> reapply functions directly in those normal use cases.

Oh, I see.  Okay, then, having a boolean argument isn't such a big
problem.  "return true" and "return false" aren't as bad, because you
only have to deal with one at a time.



More information about the whatwg mailing list