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

Exception on method when name is "registered" #45

Closed
zoechi opened this issue Oct 27, 2015 · 2 comments
Closed

Exception on method when name is "registered" #45

zoechi opened this issue Oct 27, 2015 · 2 comments

Comments

@zoechi
Copy link
Contributor

zoechi commented Oct 27, 2015

I'm not sure if this is a Polymer or Reflectable issue.

When an event handler is named registered

@PolymerRegister('some-element')
class SomeElement extends PolymerElement {
  SomeElement.created() : super.created();

  @reflectable
  void registered(dom.CustomEvent event, [_]) {...}
  // any other name than registered works just fine
}

See also http://stackoverflow.com/questions/33342798/how-do-you-listen-for-custom-events-in-polymer-dart-1-0/33342934#33342798

Observatory listening at http://127.0.0.1:46104/
Exception: Uncaught Error: Unhandled exception:
Reflecting on un-marked type 'JsObjectImpl'

0 _InstanceMirrorImpl._InstanceMirrorImpl (package:reflectable/src/reflectable_transformer_based.dart:150:9)

1 ReflectableImpl.reflect (package:reflectable/src/reflectable_transformer_based.dart:1216:16)

2 _setupReflectableMethods.. (package:polymer/src/common/polymer_descriptor.dart:151:49)

3 JsObject._callMethod (dart:js:678)

4 JsObject.callMethod (dart:js:618)

5 PolymerRegister.initialize (package:polymer/src/common/polymer_register.dart:19:13)

6 loadInitializers.. (package:initialize/src/static_loader.dart:46:32)

7 _runInitQueue (package:initialize/initialize.dart:35:24)

8 _runInitQueue. (package:initialize/initialize.dart:38:26)

9 _RootZone.runUnary (dart:async/zone.dart:1165)

10 _Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:502)

11 _Future._propagateToListeners (dart:async/future_impl.dart:585)

12 _Future._completeWithValue (dart:async/future_impl.dart:376)

13 _Future._asyncComplete. (dart:async/future_impl.dart:430)

14 _microtaskLoop (dart:async/schedule_microtask.dart:43)

15 _microtaskLoopEntry (dart:async/schedule_microtask.dart:52)

16 _ScheduleImmediateHelper._handleMutation (dart:html:42565)

Stack Trace:

0 JsObject._callMethod (dart:js:678)

1 JsObject.callMethod (dart:js:618)

2 PolymerRegister.initialize (package:polymer/src/common/polymer_register.dart:19:13)

3 loadInitializers.. (package:initialize/src/static_loader.dart:46:32)

4 _runInitQueue (package:initialize/initialize.dart:35:24)

5 _runInitQueue. (package:initialize/initialize.dart:38:26)

6 _RootZone.runUnary (dart:async/zone.dart:1165)

7 _Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:502)

8 _Future._propagateToListeners (dart:async/future_impl.dart:585)

9 _Future._completeWithValue (dart:async/future_impl.dart:376)

10 _Future._asyncComplete. (dart:async/future_impl.dart:430)

11 _microtaskLoop (dart:async/schedule_microtask.dart:43)

12 _microtaskLoopEntry (dart:async/schedule_microtask.dart:52)

13 _ScheduleImmediateHelper._handleMutation (dart:html:42565)

@sigurdm
Copy link
Collaborator

sigurdm commented Oct 27, 2015

I agree this looks suspicious. But I don't think reflectable is doing anything different with a member named "registered".

I downloaded github.com/terrasea/gcanvas and tried the web/main out in dartium - I can reproduce the app making this stack-trace when the method is named "registered" and not if named "registered2".

I tried to add formatted: true in the pubspec.yaml:transformers:reflectable section, and then running
pub build --mode=debug with the name as "registered" and "registered2" and the only difference I see in the file that reflectable generated (build/main.dart) was the name of the field.

That makes me believe the error is not related to reflectable. Does the name "registered" have any special meaning in polymer.js?

(/cc @jakemac53) any ideas?

@jakemac53
Copy link
Contributor

This is definitely a Polymer issue, Polymer JS treats a function named registered in a special way that breaks things.

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

No branches or pull requests

3 participants