initKeyEvent on KeyboardEvent should return undefined
source link: https://bugzilla.mozilla.org/show_bug.cgi?id=1717760
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
initKeyEvent on KeyboardEvent should return undefined
Categories
(Core :: DOM: Events, enhancement, P3)
Tracking
(bug RESOLVED as FIXED)
People
(Reporter: karlcow, Assigned: masayuki)
Details
(Keywords: dev-doc-complete)
var i = document.createEvent("KeyboardEvent");
typeof i.initKeyEvent;
On Firefox it returns function
On Blink and WebKit browsers, it returns undefined
This creates at least a webcompat issue on startrack.com.au
Given that it is not implemented in Safari, Chrome and Edge, I have the feeling we can safely unship it. We could try on Nightly, and discover if any sites break.
I see Masayuki mentioning initKeyEvent()
in Bug 1479964 Comment #25
I wonder if it's the relevant code.
https://searchfox.org/mozilla-central/rev/f351e19360729b351bfc7c1386d6e4ca4ea676e2/dom/events/KeyboardEvent.cpp#313-328
It's also not specified in the DOM Specification.
https://dom.spec.whatwg.org/
And defined as non standard and deprecated on MDN
https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/initKeyEvent
Masayuki, do you want to take this? I would suggest we add a preference that's false-by-default and use that to hide the method in IDL. Then if we don't notice anything we can remove it entirely after a couple of releases. Let's also do an intent to unship just in case.
Hmm, it's an old API, so, I bet that there are some web apps in the wild which use it for detecting Firefox...
I'm not sure what that means? A lot of the code there seems to make usage conditional though and uses initKeyboardEvent()
if not available, which is something all browsers expose.
Yeah, I do see some code that calls initKeyEvent
without existence check but those are just a few, and others are mostly from happen.js and jquery.simulate.js that have workarounds.
Now, Gecko is the only browser to support undocumented KeyEvent.initKeyEvent
.
We should drop it by default because typeof KeyboardEvent.initKeyEvent
is
used at least in a major web-site and which causes not working the web-site.
Depends on D121028
The webcompat team will watch out if there is new breakage where initKeyEvent would be used to identify/target Firefox.
Since the status are different for nightly and release, what's the status for beta?
For more information, please visit auto_nag documentation.
We just emailed affected developers to let them know .initKeyEvent is deprecated as of Firefox 93 and will be unshipped in Firefox 96.
FYI FF93 MDN docs for this can be tracked in https://github.com/mdn/content/issues/8623. This is just addition of release note, and making information about the deprecation and the preference more clear on the page.
When you actually remove it we'll need to do a little more work in cleanup.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK