4

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.

Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
st_clair_clarke
  • 5,453
  • 13
  • 49
  • 75

8 Answers8

6

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).

Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
dub
  • 61
  • 1
1

I just ran into the same issue. Are you sure your polymer imports are underneath your javascript imports?

<!-- <script src="packages/web_components/platform.js"></script>
     not necessary anymore with Polymer 0.14.0 -->
<script src="packages/web_components/dart_support.js"></script>
<!-- import the click-counter -->
<link rel="import" href="clickcounter.html">

instead of:

<!-- import the click-counter -->
<link rel="import" href="clickcounter.html">
<script src="packages/web_components/platform.js"></script>
<script src="packages/web_components/dart_support.js"></script>
Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
dotdotcommadot
  • 1,371
  • 1
  • 9
  • 10
  • All I changed with the generated app was to comment out the import for the and the instance created. Everything remain the same as in the initially working app. – st_clair_clarke Jul 09 '14 at 15:38
1

I think I found the solution.

The clickcounter.html |imports link rel="import" href="packages/polymer/polymer.html|". In the entry-point file, there is no such import. When a component is imported into the entry-point, it seems that the polymer.html condition is satisfied. In the absence of a component the import has to placed directly in the file.

    <!DOCTYPE html>

    <html>
      <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Sample app</title>
        <!-- <script src="packages/web_components/platform.js"></script>
             not necessary anymore with Polymer > 0.14.0 -->
        <script src="packages/web_components/dart_support.js"></script>

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

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


        <link rel="stylesheet" href="epimss_material_design.css">
      </head>
      <body>
        <h1>Epimss material design</h1>

        <p>Hello world from Dart!</p>

        <div id="sample_container_id">

        </div>

      </body>
    </html>

After that everything worked fine.

The same problem actually resurfaced in Dart SDK 1.6.0-dev.1.2 and was similarly solved. Still, I cannot say if its a bug or not. It simply works by adding this import. I suppose if a legitimate component is used that imports would allow the removal of the same import from the entry-point file. One of Dart or Dart-polymer expert might be able to explain what actually is happening. Looking forward to the in-depth explanation since this is the first time I have observed this issue.

Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
st_clair_clarke
  • 5,453
  • 13
  • 49
  • 75
1

My dummy application created from the polymer template starts fine, but once I move the clickcounter to another directory, I start getting this error (I have updated references accordingly). My new folder structure is the following:

/lib
  /src
    /test
       clickcounter.dart
       clickcounter.html
/web
  polytest.html 

This is how the modified line looks:

    <link rel="import" href="../lib/src/test/clickcounter.html">
Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
Andrew Skalkin
  • 287
  • 3
  • 10
1

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.

Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
pjv
  • 10,658
  • 6
  • 43
  • 60
0

I'm not in that development, but it seems like your problem is API or dependencies used in application.

dolf
  • 33
  • 9
0

I think your transformer settings is missing the entry page

transformers:
- polymer:
    entry_points:
    - example/index.html

Otherwise look closely at the output if there is any other warning or error that points to the root causel

Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
  • My entry page looks good. I did not even edit it. This problem is reproduced on another machine with a clean install and repeating the process. – st_clair_clarke Jul 09 '14 at 11:26
  • I also got it several times recently but I don't know what exactly caused it. When I fixed all Polymer-related things it went away. Maybe it's caused by some changed requirement after a Polymer update. – Günter Zöchbauer Jul 09 '14 at 11:28
  • I really don't know what to fix. There is no indication there is any other problems. Other dart apps previously created are running fine with all installed packages. Simply removing the component causes the problem. Its as if saving entry point does not 'recompile' for lack of a better word. The original pages seems to be 'permanently' there. It must be a problem with this Polymer or Dart versions though. – st_clair_clarke Jul 09 '14 at 11:39
  • Can you make this project available on GitHub then I can have a look. – Günter Zöchbauer Jul 09 '14 at 11:42
  • I will email a zip version to you now. Thanks – st_clair_clarke Jul 09 '14 at 11:43
  • Sent to your gmail address. Thanks – st_clair_clarke Jul 09 '14 at 11:50
  • I couldn't reproduce this issue with or without the `` element in your project. `Dart VM version: 1.6.0-edge.38076 (Tue Jul 8 17:20:13 2014) on "linux_x64"`, Polymer `0.11.0+5` – Günter Zöchbauer Jul 09 '14 at 12:00
  • Maybe its corrected in Dart VM 1.6.0, I am using Dart VM version 1.5.3 - stable| polymer 0.11.0+5. I cannot move up to 1.6.0 as yet because there is one important library that I depend on that is still at version 1.5.*. – st_clair_clarke Jul 09 '14 at 16:07
  • You can try to solve this using dependency_overrides this allows you to override/ignore dependency constraints. – Günter Zöchbauer Jul 09 '14 at 16:20
  • Thanks Gunter. I will look into this. In the mean time if you have any link as to how this is done, I would appreciate it. – st_clair_clarke Jul 09 '14 at 16:39
  • see http://stackoverflow.com/questions/23031384 or https://www.dartlang.org/tools/pub/dependencies.html. Just add a `dependency_overrides:` in addition to `dependencies:` in your `pubspec.yaml` and add the dependency with the constraint you need. `dependency_overrides: important_library: '1.3.4'` (I can't add a line break in the comment here - just format it as you would for `dependencies:`. – Günter Zöchbauer Jul 09 '14 at 16:42
  • Thanks a million. Using Dart 1.6.0-dev.1.2 brings everything back to normal. There must be a bug in 1.5.3. I appreciate the help. – st_clair_clarke Jul 09 '14 at 19:37
0

I've just had exactly the same issue. It looked like the code stopped working without any change performed by me.

Root cause of the issue was, that there appeared a new version of polymer package.

So you should probably play with dependencies in your pubspec.yaml. I just explicitly changed the version of Polymer to some older one.

René Kolařík
  • 1,244
  • 1
  • 10
  • 18