Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@mdebbar
Copy link
Contributor

@mdebbar mdebbar commented May 23, 2023

In order to use the exported PlatformLocation cross-platform, we need to remove any JS types from the interface. Namely, DomEventListener.

Required by flutter/flutter#126851

@flutter-dashboard flutter-dashboard bot added the platform-web Code specifically for the web engine label May 23, 2023
void removePopStateListener(DomEventListener fn) {
domWindow.removeEventListener('popstate', fn);
void removePopStateListener(EventListener fn) {
domWindow.removeEventListener('popstate', createDomEventListener(fn));
Copy link
Contributor Author

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

Copy link
Contributor

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.

Copy link
Contributor Author

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);
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea! Done.

@mdebbar mdebbar added the autosubmit Merge PR when tree becomes green via auto submit App label May 24, 2023
@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label May 24, 2023
@auto-submit
Copy link
Contributor

auto-submit bot commented May 24, 2023

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.

@mdebbar mdebbar added the autosubmit Merge PR when tree becomes green via auto submit App label May 24, 2023
@auto-submit auto-submit bot merged commit 50bfa81 into flutter:main May 24, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request May 24, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request May 24, 2023
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request May 24, 2023
…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
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request May 31, 2023
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
@mdebbar mdebbar deleted the hide_js_platform_location branch June 22, 2023 21:38
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

autosubmit Merge PR when tree becomes green via auto submit App platform-web Code specifically for the web engine

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants