Skip to content

Conversation

@harryterkelsen
Copy link
Contributor

Removes package:js and uses dart:js_interop instead

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@github-actions github-actions bot added a: text input Entering text in a text field or keyboard related problems engine flutter/engine related. See also e: labels. a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) f: scrolling Viewports, list views, slivers, etc. platform-web Web applications specifically f: focus Focus traversal, gaining or losing focus labels Feb 27, 2025
extension FlutterLoaderExtension on FlutterLoader {
external void didCreateEngineInitializer(FlutterEngineInitializer initializer);
bool get isAutoStart => !js_util.hasProperty(this, 'didCreateEngineInitializer');
bool get isAutoStart => !(this as JSObject).has('didCreateEngineInitializer');
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the type of FlutterLoader? is it a JSObject?


bool domInstanceOfString(Object? element, String objectType) =>
js_util.instanceOfString(element, objectType);
bool domInstanceOfString(JSAny element, String objectType) => element.instanceOfString(objectType);
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe as a follow-up, we should deprecate/remove this and just inline the call

// found in the LICENSE file.

@JS()
library js_loader;
Copy link
Contributor

Choose a reason for hiding this comment

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

We should be able to drop the library name here!

@harryterkelsen
Copy link
Contributor Author

I think I gotta put this one on pause for now. I am hitting a ton of problems with DOMEventListeners running in the wrong zone and issues with events seemingly never firing ("focus" events in particular aren't firing in tests)

@kevmoo
Copy link
Contributor

kevmoo commented Feb 28, 2025

I think I gotta put this one on pause for now. I am hitting a ton of problems with DOMEventListeners running in the wrong zone and issues with events seemingly never firing ("focus" events in particular aren't firing in tests)

😢 CC @srujzs – we should figure out if this is something systemic

@harryterkelsen
Copy link
Contributor Author

I was able to work around some of the zone issues using the technique outlined here: dart-lang/sdk#54507

However, this didn't fix the issues with the focus event seemingly never firing after calling focus() on a DOM element.

@srujzs
Copy link
Contributor

srujzs commented Mar 1, 2025

I was able to work around some of the zone issues using the technique outlined here: dart-lang/sdk#54507

Yup, I was just about to mention this. This is more or less does what dart:html does with callbacks.

However, this didn't fix the issues with the focus event seemingly never firing after calling focus() on a DOM element.

I'm happy to help debug here if you'd like to point me to the specific test. It's possible there's some unobvious semantic differences in registering the event listener.

@github-actions github-actions bot added the f: routes Navigator, Router, and related APIs. label Mar 1, 2025
@harryterkelsen
Copy link
Contributor Author

@srujzs I added this test (dom_focus_event_test.dart) when I was trying to debug the issue: https://github.com/flutter/flutter/pull/164254/files#diff-4cce257d905c908ac4719d3a062beac4d5f91ec21d616c60019e9612ebd10b74

@srujzs
Copy link
Contributor

srujzs commented Mar 3, 2025

It looks like div elements aren't focusable by default: https://javascript.info/focus-blur#allow-focusing-on-any-element-tabindex

Adding divElement.tabIndex = 1; works to get the test passing, but presumably this test is representing some other code that was working without that and before migrating. What is that other code?

If it's text_editing_test.dart, that goes from failing to passing if I revert the change to waitForTextStrategyStopPropagation, but I don't fully understand that change, so maybe it's necessary.

@kevmoo
Copy link
Contributor

kevmoo commented Mar 4, 2025

@srujzs – @harryterkelsen is on leave for many weeks. If you're bored, would you be willing to take this over?

@srujzs
Copy link
Contributor

srujzs commented Mar 4, 2025

Ah, sure, I'll take a stab at it. I'd like to get this in so that the work doesn't become stale.

@srujzs srujzs self-assigned this Mar 4, 2025
srujzs added a commit to srujzs/flutter that referenced this pull request Mar 17, 2025
Removes package:js and uses dart:js_interop instead

This is taken directly from flutter#164254 and
will be iterated on.
srujzs added a commit to srujzs/flutter that referenced this pull request Mar 17, 2025
Removes package:js and uses dart:js_interop instead

This is taken directly from flutter#164254 and
will be iterated on.
@flutter-dashboard
Copy link

This pull request executed golden file tests, but it has not been updated in a while (20+ days). Test results from Gold expire after as many days, so this pull request will need to be updated with a fresh commit in order to get results from Gold.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

github-merge-queue bot pushed a commit that referenced this pull request Mar 28, 2025
Removes package:js and uses dart:js_interop instead

This is taken directly from
#164254 and will be iterated on.

----

Initial commit is the original PR % rebasing. Follow-up commits address
test/analysis failures and commits after those clean up JS interop code:

- Remove remaining uses of `@staticInterop`.
- Code that uses JSBoolean, JSString, or JSNumber are mostly
historical relics due to not supporting primitives in externals.
Remove the redirecting functions and let the compiler handles the
conversions.
- Replace domInstanceOfString calls with isA and add @js annotations
to all extension types where needed.
- Remove unnecessary @js annotations.
- Remove unneeded implements JSObject clauses.
- Standardize naming of extension types in some cases.
- Remove JSVoid in favor of void.
- Enabled invalid_runtime_checks_with_js_interop_types lint.
- Removed unnecessary JSUint8Array constructors.

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [ ] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [ ] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.

---------

Co-authored-by: Kevin Moore <[email protected]>
@srujzs
Copy link
Contributor

srujzs commented Apr 10, 2025

This was landed with other changes in #165324, so I'm going to go ahead and close this.

@srujzs srujzs closed this Apr 10, 2025
zhangyuang pushed a commit to zhangyuang/flutter-fork that referenced this pull request Jun 9, 2025
Removes package:js and uses dart:js_interop instead

This is taken directly from
flutter#164254 and will be iterated on.

----

Initial commit is the original PR % rebasing. Follow-up commits address
test/analysis failures and commits after those clean up JS interop code:

- Remove remaining uses of `@staticInterop`.
- Code that uses JSBoolean, JSString, or JSNumber are mostly
historical relics due to not supporting primitives in externals.
Remove the redirecting functions and let the compiler handles the
conversions.
- Replace domInstanceOfString calls with isA and add @js annotations
to all extension types where needed.
- Remove unnecessary @js annotations.
- Remove unneeded implements JSObject clauses.
- Standardize naming of extension types in some cases.
- Remove JSVoid in favor of void.
- Enabled invalid_runtime_checks_with_js_interop_types lint.
- Removed unnecessary JSUint8Array constructors.

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [ ] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [ ] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.

---------

Co-authored-by: Kevin Moore <[email protected]>
romanejaquez pushed a commit to romanejaquez/flutter that referenced this pull request Aug 14, 2025
Removes package:js and uses dart:js_interop instead

This is taken directly from
flutter#164254 and will be iterated on.

----

Initial commit is the original PR % rebasing. Follow-up commits address
test/analysis failures and commits after those clean up JS interop code:

- Remove remaining uses of `@staticInterop`.
- Code that uses JSBoolean, JSString, or JSNumber are mostly
historical relics due to not supporting primitives in externals.
Remove the redirecting functions and let the compiler handles the
conversions.
- Replace domInstanceOfString calls with isA and add @js annotations
to all extension types where needed.
- Remove unnecessary @js annotations.
- Remove unneeded implements JSObject clauses.
- Standardize naming of extension types in some cases.
- Remove JSVoid in favor of void.
- Enabled invalid_runtime_checks_with_js_interop_types lint.
- Removed unnecessary JSUint8Array constructors.

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [ ] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [ ] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.

---------

Co-authored-by: Kevin Moore <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) a: text input Entering text in a text field or keyboard related problems engine flutter/engine related. See also e: labels. f: focus Focus traversal, gaining or losing focus f: routes Navigator, Router, and related APIs. f: scrolling Viewports, list views, slivers, etc. platform-web Web applications specifically

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants