1

I am experiencing some very odd problems with Polymer.dart when compiled to javascript. It works fine in Dartium. This app did work a couple of months ago. However Polymer has undergone lots of changes since then, so I have had to make loads of changes just to get it to compile. I have tried this in polymer 3.2 through to the latest build in pub, all behave the same. I am running an up to date Dart install on the stable branch.

I get the following Javascript error:

TypeError: $document.register is not a function

On the last line of the js below. The tag variable is "polymer-element".

})(H.convertDartClosureToJS(W._callAttributeChanged$closure(), 4)))};
proto = Object.create(baseConstructor.prototype, properties);
t2 = H.makeLeafDispatchRecord(interceptor);
Object.defineProperty(proto, init.dispatchPropertyName, {value: t2, enumerable: false,    writable: true, configurable: true});
options = {prototype: proto};
if (!t1)
options.extends = extendsTagName;
$document.register(tag, options); 

From what I can see the polyfills aren't loading so the document.register method hasn't been declared.

Below is from my HTML File

<head>
    <script src="index.dart" type="application/dart"></script>

    <script src="packages/browser/dart.js"></script>
    <script src="packages/browser/interop.js"></script>
</head>

My index.dart looks like

void main() {
    window.alert("Dart Lives!");

    initPolymer().run(() => initPresentation());
}


void initPresentation() {
    //Show the first screen
}

When running under Javascript I get the alert box showing followed by the Javascript error. So I don't think there is anything wrong with the basic dart environment.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Charlie M
  • 299
  • 2
  • 9

1 Answers1

0

EDIT

This has changed.
An up-to-date answer is here
Polymer querySelector working on DartVM but not in Chrome after compile

OLD

Hard to tell.

I think index.dart should look like

<head>  
  <script type='application/dart'>
    export 'index.dart';
  </script>
</head>

or

<body>

  ...
  <script type='application/dart' src='index.dart'></script>
</body>

see https://code.google.com/p/dart/issues/detail?id=17546#c16

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