Add Event and requestAnimationFrame helpers and fix createBlob - #567
Conversation
There was a problem hiding this comment.
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.
|
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! |
|
Thanks Kevin! |
CustomEvents were handled specially indart:htmlbyjsifying compatibledetails and otherwise storing it on the side in variable. When accessingdetail, it would check for this storage on the side first before directly returning the nativedetail. We could store it on the side here but that won't be symmetric withdart:html, so we leverage the nativedetailto store the object.EventandKeyboardEventconstructors fromdart:htmlhave different defaults than the web, so that's reflected here as well.requestAnimationFramebound the current zone before, so there's a helper for that (mostly so users are aware that that is the equivalent member).Lastly,
createBlobshould have been static so this fixes that.