dint-dev / universal_html

Cross-platform 'dart:html'.
https://pub.dev/packages/universal_html
Apache License 2.0
201 stars 60 forks source link

HttpRequest load fix #83

Closed fsw closed 1 year ago

fsw commented 1 year ago

Because this event was missing, using HttpRequest with onLoad listener was not working as listener was never called:

    var xhr = HttpRequest();
    xhr.open('GET', 'https://swift.shop', async: true);
    xhr.onLoad.listen((e) {
      print('LOADED');
    });
    xhr.send();

This event was also used internally in request method so methods like getString were not working as well:

    HttpRequest.getString('https://github.com').then((content) {
      print(content);
    });

I think that this is a correct moment to send this event according to specs. https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/load_event

I have added a test for getString method that fails without this fix.

terrier989 commented 1 year ago

Thank you for the pull request again! 👍