- From: Ben Peters <Ben.Peters@microsoft.com>
- Date: Tue, 20 May 2014 17:53:31 +0000
- To: Anne van Kesteren <annevk@annevk.nl>, "Hallvord R. M. Steen" <hsteen@mozilla.com>
- CC: public-webapps <public-webapps@w3.org>
> <!DOCTYPE html> > <a href="http://example.org/">wut</a> > <script>document.querySelector("a").dispatchEvent(new > Event("click"))</script> > > Does not cause a navigate action. This does: > > <script>document.querySelector("a").click()</script> > This is related to what I've been thinking for CommandEvent [1] [2], in that we need a really clear way to both invoke actions (execCommand) and overwrite their meaning (ClipbboardEvent, CommandEvent). > > > Calling document.execCommand('copy') will by itself dispatch a "copy" > event. > > Yes. It initiates a copy action. As part of that action an event is dispatched to > inform listeners and allow them to interfere with the action flow. But > confusing the two is very wrong. An end-user moving the mouse is an action, > the mousemove event is just a result of that action and does not actually > cause the mouse to move. > > > > I wonder how fancy we can get with execCommand()'s value argument? > Could we go for something like this instead of the scripted event payload? > > > > document.execCommand('copy', false, {'text/plain':'Hello', > 'text/html':'<p><b>Hello</b></p>'});? > > Maybe, or we could propose a new API. > I've been thinking about this too. I like the idea here. Another one would be to have a Command object, like this: document.execCommand({'commandName':'copy', 'text/plain':'Hello', 'text/html':'<p><b>Hello</b></p>'}); Which means we could get rid of the nearly-meaningless second argument to execCommand without needing to introduce a new function. I'm in the process of writing a doc on all this (simple version on the wiki [1]), and I would love input. Ben [1] https://github.com/w3c/editing-explainer/wiki/CommandEvent [2] http://lists.w3.org/Archives/Public/public-webapps/2014AprJun/0298.html
Received on Tuesday, 20 May 2014 17:54:02 UTC