Search code examples
dartdart-polymerpolymer

No custom elements in polymer app


I have a polymer app that runs fine i Dartium, but when I export to javascript it will not run. There are no error messages, but I get this warning:

Target of URI does not exist: 'maindocument.html.0.dart'

It refers to this line:

<script type="application/dart" src="maindocument.html.0.dart"></script>

in a file called 'maindocument.html' created by the build.

This is the 'original' 'maindocument.html':

<!DOCTYPE html>

<html>
  <head>
    <meta charset="utf-8">
    <title>Sample app</title>
    <link rel="stylesheet" href="maindocument.css">

    <link rel="import" href="maincontroller.html">

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

    <div id="sample_container_id">
      <main-controller></main-controller>
    </div>

  </body>
</html>

This is 'maincontroller.html':

<link rel="import" href="postedItem.html">

<polymer-element name="main-controller">
  <template>
    <style>
    </style>
    <div>
      <posted-item></posted-item>
    </div>
  </template>
  <script type="application/dart" src="maincontroller.dart"></script>
</polymer-element>

'maincontroller.dart' has no functionality yet. Is it a problem with nested custom elements?


Solution

  • If maincontroller.dart does not have a definition for MainController with a CustomTag annotation, then you'll have problems.

    Try defining a MainController class or add a noscript attribute to your <polymer-element> tag if you don't need any code for your element.