Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exception: NoSuchMethodError: method not found: 'whenPolymerReady'

I am using Dart SDK 1.5.3 | polymer 0.11.0+5 | Windows x64. When I create a created a polymer application using the template 'Sample web application using the polymer library (mobile friendly) option' and run the application it works as expected with the counter incrementing when the button is clicked.

Assuming the page with the

<script type="application/dart">
  export 'package:polymer/init.dart';
</script>

is index.html, attempting to refactor the application by removing the following lines from index.html

<click-counter count="5"></click-counter>
<link rel="import" href="clickcounter.html">

results in the following error:

Exception: NoSuchMethodError: method not found: 'whenPolymerReady'
Receiver: Instance of 'JsFunction'
Arguments: [Closure: () => dynamic] (package:polymer/src/loader.dart:115)
Breaking on exception: NoSuchMethodError: method not found: 'whenPolymerReady'

I have used the mechanism all the time in creating any polymer app, but has never seen such exception although I have seen documentation on the web involving Dart https://www.google.com.jm/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0CBwQFjAA&url=http%3A%2F%2Fcode.google.com%2Fp%2Fdart%2Fissues%2Fdetail%3Fid%3D19161&ei=MZq8U_nlK42KyASBkYHgCw&usg=AFQjCNHOc6MD-mhzPbDOmg8Hp5NeqVufqQ&bvm=bv.70138588,d.aWw

The documentation suggested that this problem had resolved but it certainly is present in the current polymer I am using.

like image 896
st_clair_clarke Avatar asked Dec 26 '22 07:12

st_clair_clarke


2 Answers

Each of your components (each file containing a <polymer-element> tag) must import polymer.html.

Make sure your clickcounter.html contains the line:

<link rel="import" href="packages/polymer/polymer.html" />

at the top. (It was breaking change in 0.11).

like image 69
dub Avatar answered Dec 28 '22 08:12

dub


I'm clueless about these things, but for me I seemed to solve it by moving the following code:

<!-- after the Polymer elements imports -->
<script type="application/dart">export 'package:polymer/init.dart';</script>    
<script async src="packages/browser/dart.js"></script>

from the end of the <head>er, to just before the </body>. Only my index.html now contains these lines. Lastly I also moved my custom element import above core-elements/paper-elements imports.

like image 22
pjv Avatar answered Dec 28 '22 07:12

pjv