Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

event.detail is incorrect and inconsistent between dart2js and dartium #20648

Closed
sigmundch opened this issue Aug 21, 2014 · 10 comments
Closed

event.detail is incorrect and inconsistent between dart2js and dartium #20648

sigmundch opened this issue Aug 21, 2014 · 10 comments
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. closed-obsolete Closed as the reported issue is no longer relevant library-html P1 A high priority bug; for example, a single project is unusable or has many test failures type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@sigmundch
Copy link
Member

If the event contains a JSON object containing a proxy to a Dart object, the result:
 - is null in dartium, but not null in JS.
 - in JS it returns an map containing the JsObject for the proxy, rather than the unwrapped object.

Here is a simple example that can repro this problem:

<body>
  <script>
  function fire(item) {
    var event = new CustomEvent('my-event', {detail: {item: item}});
    document.body.dispatchEvent(event);
  }
  </script>
  <script type="application/dart" src="index.dart"></script>
  <script src="packages/browser/dart.js"></script>

index.dart:

  import 'dart:html';
  import 'dart:js';
  main() {
    document.body.on['my-event'].listen((e) {
      if (e.detail != null) {
        var d = e.detail["item"];
        print('0: ${d}, type: ${d.runtimeType}');
      } else {
        print('0: null');
      }
      var d = new JsObject.fromBrowserObject(e)['detail']['item'];
      print('1: $d, type: ${d.runtimeType}');
    });
    context['fire'].apply([new _Foo()]);
  }
  class _Foo { int id = 3; }

In dartium, this prints '0: null', in dart2js it prints '0: [object Object], type: JSObject ', where the object happens to be the JsObject proxy for _Foo

The second line prints the same result in both: 1: Instance of '_Foo', type: \_Foo. I expect there result to always be like this line.

This is related to bug 19315, but I'd like to make sure we track separately the inconsistency between the two implementations today.

@efortuna
Copy link
Contributor

Set owner to @efortuna.

@efortuna
Copy link
Contributor

efortuna commented Sep 8, 2014

assigning to Siggi, as he talked about doing this one


Set owner to @sigmundch.

@sigmundch
Copy link
Member Author

I started investigating how to fix the overall problem described in bug 19315, so I might fix this together with that.

If we decide to keep that separate from the fix here, the issue here seems to be that dart:html for dart2js assumes that event.detail was set earlier via the initialization code in dart:html, and doesn't consider events that were initially set in JS.

See:
https://code.google.com/p/dart/source/browse/branches/bleeding_edge/dart/sdk/lib/html/html_common/conversions.dart?r=32521#­288

@sigmundch
Copy link
Member Author

Removed this from the 1.7 milestone.
Added this to the 1.8 milestone.
Removed Priority-High label.
Added Priority-Medium label.

@kasperl
Copy link

kasperl commented Oct 15, 2014

Since this is assigned to the 1.8 milestone, I'm bumping the priority to high. Feel free to lower the priority and remove the 1.8 milestone marker.


Removed Priority-Medium label.
Added Priority-High label.

@kasperl
Copy link

kasperl commented Nov 28, 2014

Removed this from the 1.8 milestone.
Added this to the 1.9 milestone.

@kasperl
Copy link

kasperl commented Nov 28, 2014

Added Accepted label.

@sigmundch
Copy link
Member Author

Removed the owner.
Removed this from the 1.9 milestone.
Added this to the 1.10 milestone.
Added Triaged label.

@kevmoo
Copy link
Member

kevmoo commented Apr 20, 2015

Removed this from the 1.10 milestone.

@sigmundch sigmundch added Type-Defect area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-html P1 A high priority bug; for example, a single project is unusable or has many test failures labels Apr 20, 2015
@kevmoo kevmoo added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) and removed triaged labels Mar 1, 2016
@matanlurey matanlurey added the closed-obsolete Closed as the reported issue is no longer relevant label Jun 19, 2018
@matanlurey
Copy link
Contributor

Dartium is no longer supported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. closed-obsolete Closed as the reported issue is no longer relevant library-html P1 A high priority bug; for example, a single project is unusable or has many test failures type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

5 participants