- From: Ryosuke Niwa <rniwa@webkit.org>
- Date: Fri, 24 Aug 2012 13:18:27 -0700
- To: Sukolsak Sakshuwong <sukolsak@google.com>
- Cc: public-webapps@w3.org
- Message-ID: <CABNRm62RuEb0XUhbVdzDNn1wGSvuT9ECcYYhFCEW9e6_9uQxTg@mail.gmail.com>
On Fri, Aug 24, 2012 at 12:45 PM, Sukolsak Sakshuwong <sukolsak@google.com>wrote: > According to the UndoManager spec > ( > http://dvcs.w3.org/hg/undomanager/raw-file/tip/undomanager.html#dom-undomanager-undo > ), > we fire an undo event whenever undoManager.undo() is called. However, > the spec is kind of ambiguous in regard to multiple DOM transactions. > For example, there can be multiple DOM transactions in one entry, > which can be achieved by using undoManager.transact(..., true). How > should we fire an undo event in this case, and which transaction > should we set on the event object? For example, > > <!DOCTYPE html> > <html> > <body> > <script> > var listener = function(event) { > console.log("undo event fired"); > }; > document.addEventListener("undo", listener, false); > > var transaction = { > "execute": function() {}, > "undo": function() { console.log("undo"); }, > "redo": function() {} > }; > var undoManager = document.undoManager; > undoManager.transact(transaction, false); > undoManager.transact(transaction, true); > undoManager.undo(); > </script> > </body> > </html> > > What should be the output from the console in this example? > > 1. > undo > undo event fired > undo > undo event fired > > or > > 2. > undo > undo > undo event fired > undo event fired > Between these two options, the first option makes a lot more sense because the first event handler may have done some work and affected other undos or that the event handler for the first undo event may expect DOM to be at a certain state. 3. > undo > undo > undo event fired (Which transaction should event.transaction return?) > We can add "transactions" property instead. For merged transactions, we can either have an array with new transaction as its sole element or pass in the entire sequence of transactions where the last entry is the new one. - Ryosuke
Received on Friday, 24 August 2012 20:19:22 UTC