Hello I have a working Polymer 1.0 web page on Chrome and Opera. Now I need the page to run in Firefox and Safari. I have the following test:
<!DOCTYPE html>
<html>
<head>
<?php use Cake\Routing\Router; ?>
<?php echo $this->Html->script('/bower_components/webcomponentsjs/webcomponents-lite.min.js'); ?>
<link rel="import" href="<?= Router::url('/'); ?>bower_components/polymer/polymer.html">
<dom-module id="test-element">
<template >
<h1>It works</h1>
</template>
<script>
Polymer({
is: "test-element"
});
</script>
</dom-module>
</head>
<body unresolved>
<test-element></test-element>
</body>
</html>
I have tried changing
<?php echo $this->Html->script('/bower_components/webcomponentsjs/webcomponents-lite.min.js'); ?>
to
<?php echo $this->Html->script('/bower_components/webcomponentsjs/webcomponents.js'); ?>
or
<?php echo $this->Html->script('/bower_components/webcomponentsjs/webcomponents.min.js'); ?>
I thought the Polyfills of webcomponents would take care of the html import. But it's not working. In firefox I get the following error:
ReferenceError: Polymer is not defined
I haven't been able to test it with Safari but I expect a similar result.
Am I doing anything wrong? how can I make this work?
Also I tried deleting the webcomponents and runing bower update to install them again.
thank you
EDIT:
I have two files. index.html:
<!DOCTYPE html>
<html>
<head>
<?php use Cake\Routing\Router; ?>
<?php echo $this->Html->script('/bower_components/webcomponentsjs/webcomponents.js'); ?>
<link rel="import" href="<?= Router::url('/'); ?>bower_components/polymer/polymer.html">
<?= $this->element('Polymer/test-element');?>
</head>
<body unresolved>
<test-element></test-element>
</body>
</html>
and the element file:
<dom-module id="test-element">
<template >
<h1>It works</h1>
</template>
<script>
addEventListener('WebComponentsReady', function() {
Polymer({
is: "test-element"
});
});
</script>
</dom-module>
This works fine. My problem is if I delete the addEventListener. The Firefox gets the same error:
ReferenceError: Polymer is not defined
As if Polyfills were not loaded in time. Is there a way to fix this? Is adding the addEventListener the right way to do it?
Thank you