JavaScript built and minified with dart2js does not handle SubmitEvent properly.

Dart VM version: 2.7.1
MacOS Catalina 10.15.3
Firefox Nightly 75.0a1

I was making a very simple web app, and while it had no errors when served using webdev serve, after using webdev build and serving the production files, I get the following error in the console.

: TypeError: Instance of 'bG': type 'bG' is not a subtype of type 'minified:k'

I’ve tried using Chrome and had no problems. And I booted up an Ubuntu machine I have with normal Firefox installed and had no problems there either.

This is the repository where I’m having the problem: https://github.com/mcaubrey/simple_dart_weather

I realize this could just be a problem with Nightly, and I’ll try to make bug report on Bugzilla.

Author: Fantashit

2 thoughts on “JavaScript built and minified with dart2js does not handle SubmitEvent properly.

  1. FirefoxNightly dispatches the form submit event with SubmitEvent, that seems not to be handled in dart.
    added by https://bugzilla.mozilla.org/show_bug.cgi?id=1588715

    the example code receives the parameter with Event type:
    https://github.com/mcaubrey/simple_dart_weather/blob/a2137f19c1f5152798d85099966d86869eca8fe1/web/main.dart#L10
    and it looks like SubmitEvent isn’t treated as a subtype of Event.

    If I add SubmitEvent to the object passed to hunkHelpers.setOrUpdateInterceptorsByTag call, in generated code in https://www.michaelcharl.es/aubrey/sample/main.dart.js
    the issue doesn’t happen.

    prettified code below:

            hunkHelpers.setOrUpdateInterceptorsByTag({
    ...
                Event: W.k,
                SubmitEvent: W.k,  // <-- added here
                InputEvent: W.k,
    ...
            })
    
    

    so, it sounds like, the inheritance isn’t handled properly for unknown interface.

  2. There is a hook for mapping unknown ‘native’ classes to existing ‘native’ classes.
    Put this in your html file ahead of the script tag that loads the dart app:

    <script>
    if (typeof dartNativeDispatchHooksTransformer == "undefined") dartNativeDispatchHooksTransformer=[];
    dartNativeDispatchHooksTransformer.push(
    function(hooks) {
      var getTag = hooks.getTag;
      var quickMap = {
          "SubmitEvent": "Event",
      };
      function getTagFixed(o) {
        var tag = getTag(o);
        return quickMap[tag] || tag;
      }
      hooks.getTag = getTagFixed;
    });
    </script>

    What it does is make a SubmitEvent appear to the Dart program as a plain Event.

    @srujzs We can change the dart:html library to do something similar automatically.

Comments are closed.