Reputation: 2081
I got a strange behavior when my polymer web-component loads in firefox.
The problem is, that the javascript after
<content></content>
is not loaded in firefox but works as expected in chrome.
I use polymer version 1.0
My element looks like this:
<link rel="import" href="../../../../bower_components/polymer/polymer.html">
<dom-module id="my-element">
<style>
...style content
</style>
<template>
<svg ...my svg></svg>
<content></content>
<script> --> This script is not loaded in firefox.
...script content
</script>
</template>
</dom-module>
<script>
Polymer({
is: 'my-element'
... etc ...
});
</script>
Help would be greatly apreciated.
Upvotes: 0
Views: 318
Reputation: 21
I had the same problem, but rereading the documentation I found the solution.
Before loading Polymer Script you need wait for the DOM to be ready, like this:
<dom-module id="my-element">
<template>
<svg ...></svg>
<content></content>
</template>
<script>
HTMLImports.whenReady(function () {
Polymer({
is: 'my-element'
// (...)
});
});
</script>
</dom-module>
<my-element></my-element>
Upvotes: 2
Reputation: 4474
Instead of having a script tag inside the template you could use one of the lifecycle methods of the component like "attached" to do the same.
Upvotes: 0