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

Re: Automatic DOM transactions in UndoManager

From: Ryosuke Niwa <rniwa@webkit.org>
Date: Sun, 12 Aug 2012 02:20:15 -0700
Message-ID: <CABNRm62+Z=3g=6M7fhAdz9rmdwqJ72CwDx6yUT8bzTLxs1AECg@mail.gmail.com>
To: Sukolsak Sakshuwong <sukolsak@google.com>
Cc: public-webapps@w3.org, Jonas Sicking <jonas@sicking.cc>, Olli@pettay.fi, Ehsan Akhgari <ehsan@mozilla.com>, Ojan Vafai <ojan@chromium.org>
For the simplicity, I would like to keep the current spec, and let that
transaction fail. Any opinions?

On Mon, Aug 6, 2012 at 6:03 PM, Sukolsak Sakshuwong <sukolsak@google.com>wrote:

> Should we be able to revert the following transaction?
>
> <!DOCTYPE html>
> <html>
> <body>
> <div id="a">Hello</div>
> <script>
> var a = document.getElementById("a");
>
> document.undoManager.transact({
>         "executeAutomatic": function () {
>                 var b = document.createElement("div");
>                 b.appendChild(a);
>         }
> });
>
> document.undoManager.undo();
> </script>
> <body>
> </html>
>
> Note that there are two DOM changes occurring inside the
> executeAutomatic function:
> 1. "a" is removed from its parent.
> 2. "a" is added as a child of "b".
>
> Only the first DOM change is recorded. The second DOM change is not
> recorded because "b" is not a descendant of the undo scope host, which
> is the document in this case.
>
> Therefore, only the first DOM change will be reverted. However,
> according to the spec
> (
> http://dvcs.w3.org/hg/undomanager/raw-file/tip/undomanager.html#reverting-dom-changes
> ),
> we can't revert it because a's parent is not null. Thus, "a" will not
> be added back to the document.
>
>
>
Received on Sunday, 12 August 2012 09:21:02 GMT

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