Description
Several APIs in dart:html are incomplete and some have been hidden in our code generator as private classes. Users have run into scenarios where they want to use these classes but they find that they are incomplete, and the standard way of using Js-interop doesn't work in dart2js.
See two examples:
_USBDevice
: dart2js vs. DDC: How to cast List<dynamic> Promise callbacks (specific: navigator.usb.getDevices callback) #39147_SubtleCrypto
: NoMethodFoundError only during 'webdev serve --release' but not in 'webdev serve' for JS Interop #42194
The users noticed that the API is hidden, so they tried using @JS
to access it directly. This creates an issue because dart2js associates the dart:html interceptor with those types, so their JS-interop interfaces don't work. The only mechanism that works for them is to: store the objects in a dynamic variable and invoke it's methods via js_util.callMethod
.
Some ways to address the original issue would be to:
- delete our definition - so that the js-interop definitions can work without conflict
- expose our definition (even if empty), and allow extension methods to include new external members that can be implemented via js-interop.
The former would work right away, but could potentially be a source of breaking changes in the future if we were to add back the definition in the future. The latter requires compiler work (support for external extension methods is not available), so the fix will not be available as quickly.