I'm using a number of core-ajax-dart elements on a web page. The custom events firing seems to be broken. When using the declarative on-core-response="{{ajaxNewProjectResponse}}"
the element seems to want to fire the custom event, but there's a smoke package in the way that gives:
Missing method "null" in competences-service. Code generation for the smoke package seems incomplete.
If I do it imperatively, through ajaxNewProject.onCoreResponse.listen(ajaxNewProjectResponse);
, it does work as expected (the event fires and my event method is called).
This used to work. I suspect it may have broken when updating polymer or core_elements versions, or when I started using more and more core-ajax-dart elements.
What I understand from the smoke package is that it may be related to the polymer transformer. The error leads me to believe that some code was not properly generated, and so may point out a framework bug, not a bug in my code. I could find relatively little about this error message, only https://groups.google.com/a/dartlang.org/forum/#!topic/web/INNHAZhLy1A, but I am not hiding expressions in strings in code. Am I on the right track here?
Error:
Exception: Uncaught Error: Missing method "null" in competences-service. Code generation for the smoke package seems incomplete.
Stack Trace:
#0 GeneratedObjectAccessorService.invoke (package:smoke/static.dart:127:7)
#1 invoke (package:smoke/smoke.dart:43:41)
#2 HtmlElement&Polymer.dispatchMethod (package:polymer/src/instance.dart:1138:19)
#3 BindingDelegate&PolymerEventBindings.getEventHandler.<anonymous closure> (package:polymer/src/events.dart:82:32)
#4 _RootZone.runUnaryGuarded (dart:async/zone.dart:1089)
#5 _RootZone.bindUnaryCallback.<anonymous closure> (dart:async/zone.dart:1118)
#6 BindingDelegate&PolymerEventBindings.prepareEventBinding.<anonymous closure>.<anonymous closure> (package:polymer/src/events.dart:101:67)
#7 BlinkEventTarget.dispatchEvent_Callback_Event (dart:_blink:42)
#8 EventTarget.dispatchEvent (dart:html:13924)
#9 HtmlElement&Polymer.fire (package:polymer/src/instance.dart:1201:23)
#10 CoreAjax.processResponse (package:core_elements/core_ajax_dart.dart:208:14)
#11 receive (package:core_elements/core_ajax_dart.dart:190:27)
#12 CoreXhr._makeReadyStateHandler.<anonymous closure> (package:core_elements/core_xhr_dart.dart:107:39)
My code: The full code on https://github.com/pjjjv/Akepot/tree/0b093b2b9671f4ce0351750d9ce3609dfb4e82f5. The core-ajax-dart elements are in lib/competences_service.html and to show the bug I have left the one with id ajaxNewProject with the declarative event handler.
An excerpt: Html:
<core-ajax-dart id="ajaxNewProject"
url="https://1-dot-akepot-competence-matrix.appspot.com/_ah/api/akepot/v1/project/"
on-core-response="{{ajaxNewProjectResponse}}" on-core-error="{{ajaxError}}"
handleAs="json" method="POST">
</core-ajax-dart>
Dart:
void newProject(Project project){
if(!signedin){
throw new Exception("Not signed in.");
}
ajaxNewProject.url = "https://1-dot-akepot-competence-matrix.appspot.com/_ah/api/akepot/v1/project/$hash";
ajaxNewProject.body = JSON.encode(project.toJson());
ajaxNewProject.go();
}
@reflectable
void ajaxNewProjectResponse(CustomEvent event, Map detail, CoreAjax node) {
...
}
If you run the app, sign in at the left top, click Create project and then click Create project again. Then check the console.