W3C home > Mailing lists > Public > public-webapps@w3.org > July to September 2012

DOMTransactionEvent in UndoManager

From: Sukolsak Sakshuwong <sukolsak@google.com>
Date: Fri, 24 Aug 2012 12:45:09 -0700
Message-ID: <CAJgW9=hWY6myp2Won3E+J5QeHjcB4rA82noXJcYMm5OSFjVroQ@mail.gmail.com>
To: public-webapps@w3.org
Hi all,

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

or

3.
undo
undo
undo event fired (Which transaction should event.transaction return?)

Best regards,
Sukolsak Sakshuwong
Received on Friday, 24 August 2012 19:48:40 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:54 GMT