-
Notifications
You must be signed in to change notification settings - Fork 6k
[web] Hide JS types from dart:ui_web #42252
Conversation
| void removePopStateListener(DomEventListener fn) { | ||
| domWindow.removeEventListener('popstate', fn); | ||
| void removePopStateListener(EventListener fn) { | ||
| domWindow.removeEventListener('popstate', createDomEventListener(fn)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just realized that this may not work because it creates a new function that's different from the one passed to domWindow.addEventListener().
Does Function.toJS create a new JS function on each invocation? Or does it cache and return the same JS function? cc @joshualitt @eyebrowsoffire
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ran into this too when I tried to migrate the plugins. Function.toJS creates a new function.
My 'fix' was to create a cache locally in this file to do the deduping. Another option is to change this API to take a JSFunction.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This API used to take a JSFunction but I had to change it because we don't want to expose a JS type in the interface of the PlatformLocation class.
I think it's reasonable to have a cache inside the BrowserPlatformLocation class.
| void removePopStateListener(DomEventListener fn) { | ||
| domWindow.removeEventListener('popstate', fn); | ||
| void removePopStateListener(EventListener fn) { | ||
| final DomEventListener jsFn = getOrCreateDomEventListener(fn); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to throw if a user tries to remove a listener that was never added?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great idea! Done.
|
auto label is removed for flutter/engine, pr: 42252, due to - The status or check suite Linux mac_unopt has failed. Please fix the issues identified (or deflake) before re-applying this label. |
…127536) flutter/engine@c641f63...9ba461e 2023-05-24 [email protected] [web] Remove comment about dart:html migration (flutter/engine#42290) 2023-05-24 [email protected] [web] Hide JS types from dart:ui_web (flutter/engine#42252) 2023-05-24 [email protected] Roll Fuchsia Mac SDK from qoLy9E5PjnAlICjUb... to RSSC61ubl9JXmn4JO... (flutter/engine#42287) 2023-05-24 [email protected] [web] Update a11y announcements to append divs instead of setting content. (flutter/engine#42258) 2023-05-24 [email protected] [Impeller] fix Xcode frame capture. (flutter/engine#42289) 2023-05-24 [email protected] [Impeller] Create an autorelease pool for Impeller tests running on macOS. (flutter/engine#42265) Also rolling transitive DEPS: fuchsia/sdk/core/mac-amd64 from qoLy9E5PjnAl to RSSC61ubl9JX If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Remove the following APIs and export them directly from `dart:ui_web`: - `urlStrategy` getter and setter - `HashUrlStrategy` - `PlatformLocation` and `BrowserPlatformLocation` (keep the façades for non-web platforms) Depends on flutter/engine#42043 Depends on flutter/engine#42252 Part of #126831
In order to use the exported
PlatformLocationcross-platform, we need to remove any JS types from the interface. Namely,DomEventListener.Required by flutter/flutter#126851