Getter Jetter
Getter Jetter

Reputation: 2081

Polymer web-component inline script not loaded in firefox

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

Answers (2)

Jo&#227;o H&#233;lio
Jo&#227;o H&#233;lio

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

Hugo Zapata
Hugo Zapata

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

Related Questions