html
html copied to clipboard
Move oncopy/oncut/onpaste to GlobalEventHandlers
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 )
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.
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?
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.
@EdgarChen might be the right point of contact for Gecko
Preparing https://github.com/web-platform-tests/wpt/pull/36398 made it clear that SVG and MathML changes will also be needed here.
I've sent PRs to update SVG and MathML: https://github.com/w3c/svgwg/pull/895 + https://github.com/w3c/mathml-core/pull/171
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.