google / closure-library

Google's common JavaScript library
code.google.com/closure/library/
Apache License 2.0
4.88k stars 1.05k forks source link

Firefox specific execCommands no longer needed #1210

Closed johanneswilm closed 11 months ago

johanneswilm commented 11 months ago

Hey, Firefox stopped requiring disabling controls five years ago [1]. So you are now able to remove your last usages of document.execCommand for things like "enableInlineTableEditing" or "enableObjectResizing".

[1] https://bugzilla.mozilla.org/show_bug.cgi?id=1490641

shicks commented 11 months ago

Are there plans to remove this API? It sounds like the call currently does nothing, but we have a dozen and a half calls to document.execCommand for various commands across various browsers? They're marked as deprecated in our externs, but are they all actually no-ops, or do we need to find an appropriate replacement for each?

johanneswilm commented 11 months ago

@shicks There are some execCommands that actually do certain dom changes. You are discouraged to use those, but maybe you have decided to use them anyway instead of writing the dom modification JS yourself. Then there is the document.execCommand('copy') which cannot be replaced fully yet, as the async Clipboard API is still behind a flag in Firefox.

This bug report is about the third kind of execCommands - the ones that don't do anything and therefore can be removed entirely without needing any replacement. The story behind them is this: up until a few years ago, Firefox had added special controls on images and tables when inside of contenteditable elements. Almost all JS editors executed two execCommands in order to get Firefox to behave like all other browsers. Five years ago, Firefox finally changed to the same default behavior as all other browsers. The execCommands for "enableInlineTableEditing" and "enableObjectResizing" can therefore be deleted from all JS editor code and it will not change any behavior.

johanneswilm commented 11 months ago

In this library, the code that shoudl be removed is here:

https://github.com/google/closure-library/blob/11b2f3c3955bb25afade5553bb759a5c6ff34041/closure/goog/editor/seamlessfield.js#L502-L503