Skip to content

Add Event and requestAnimationFrame helpers and fix createBlob - #567

Merged
srujzs merged 2 commits into
dart-lang:mainfrom
srujzs:morehelpers
Aug 12, 2026
Merged

Add Event and requestAnimationFrame helpers and fix createBlob#567
srujzs merged 2 commits into
dart-lang:mainfrom
srujzs:morehelpers

Conversation

@srujzs

@srujzs srujzs commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

CustomEvents were handled specially in dart:html by jsifying compatible details and otherwise storing it on the side in variable. When accessing detail, it would check for this storage on the side first before directly returning the native detail. We could store it on the side here but that won't be symmetric with dart:html, so we leverage the native detail to store the object.

Event and KeyboardEvent constructors from dart:html have different defaults than the web, so that's reflected here as well.

requestAnimationFrame bound the current zone before, so there's a helper for that (mostly so users are aware that that is the equivalent member).

Lastly, createBlob should have been static so this fixes that.

@srujzs
srujzs requested a review from kevmoo August 12, 2026 00:08

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces several extension methods and static helpers for DOM classes such as Blob, CustomEvent, Event, KeyboardEvent, and Window to ease migrations and compatibility. The review feedback highlights critical issues in the new extensions: a potential compile-time or runtime error in createCustomEvent due to unsafe handling of the nullable detail parameter, a logical bug in dartDetail where checking isA<JSAny?>() is always true and creates dead code, and a missing static keyword on createKeyboardEvent which prevents it from functioning as a constructor replacement helper.

Comment thread web/lib/src/helpers/extensions.dart
Comment thread web/lib/src/helpers/extensions.dart
Comment thread web/lib/src/helpers/extensions.dart Outdated
@kevmoo

kevmoo commented Aug 12, 2026

Copy link
Copy Markdown
Member

We have some integration test bits. Any way to test these?

@srujzs

srujzs commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

We have some integration test bits. Any way to test these?

Yeah we should be a bit better about a lot of these helpers. I think the hope is they get removed eventually, but anyways, done!

@srujzs

srujzs commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

Thanks Kevin!

@srujzs
srujzs merged commit 6b84f81 into dart-lang:main Aug 12, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants