html icon indicating copy to clipboard operation
html copied to clipboard

Move oncopy/oncut/onpaste to GlobalEventHandlers

Open foolip opened this issue 3 years ago • 4 comments

Fixes https://github.com/whatwg/html/issues/8053.

  • [x] At least two implementers are interested (and none opposed):
    • @garykac for Chromium in https://github.com/whatwg/html/pull/8096#issuecomment-1180352825
    • @saschanaz for Gecko in https://github.com/whatwg/html/pull/8096#pullrequestreview-1040771522
    • WebKit?
  • [ ] Tests are written and can be reviewed and commented upon at:
  • [ ] Implementation bugs are filed:
    • Chrome: …
    • Firefox: …
    • Safari: …
    • Deno (only for timers, structured clone, base64 utils, channel messaging, module resolution, web workers, and web storage): …
    • Node.js (only for timers, structured clone, base64 utils, channel messaging, and module resolution): …

(See WHATWG Working Mode: Changes for more details.)


/dom.html ( diff ) /webappapis.html ( diff )

foolip avatar Jul 11 '22 11:07 foolip

Testing this will mostly be covered by idlharness.js tests which will be updated after this PR lands. But we should also test that the content attributes, something like this:

var element = document.body;
var events = ['copy', 'cut', 'paste'];
for (var type of events) {
  var handler = `on${type}`;
  assert_equals(element[handler], null);
  element.setAttribute(handler, '()=>{}');
  assert_not_equals(element[handler], null);
}

But I'll wait with that until implementer interest is clear.

foolip avatar Jul 11 '22 12:07 foolip

Since this is clipboard related, @garykac do you think this makes sense in Chromium? This amounts to adding oncopy and friends to window, since the events bubble to window but were never added there because (seemingly) IE didn't have the handler attributes there.

@jgraham do you know who could look at this for Gecko?

@cdumez do you know who could look at this for WebKit?

foolip avatar Jul 11 '22 12:07 foolip

This change sounds good to me.

I didn't see any changes that would be required in the Clipboard spec because of this change. It refers to the "current document selection" which would still have a clear definition in a window context.

garykac avatar Jul 11 '22 12:07 garykac

@EdgarChen might be the right point of contact for Gecko

jgraham avatar Jul 12 '22 13:07 jgraham

Preparing https://github.com/web-platform-tests/wpt/pull/36398 made it clear that SVG and MathML changes will also be needed here.

foolip avatar Oct 11 '22 10:10 foolip

I've sent PRs to update SVG and MathML: https://github.com/w3c/svgwg/pull/895 + https://github.com/w3c/mathml-core/pull/171

foolip avatar Oct 11 '22 10:10 foolip

https://github.com/w3c/svgwg/pull/895 and https://github.com/w3c/mathml-core/pull/171 are now reviewed. I'll file the remaining implementation bugs and then merge this.

foolip avatar Dec 21 '22 08:12 foolip