Jessie Jessie - 4 months ago 8
CSS Question

Polymer fix messing up Javascript

I'm new to Polymer and as far as I've read about it, it isn't compatible with Mozilla and Safari or it has issues. I've read in StackOverflow that adding

addEventListener('WebComponentsReady', function() {
});


would help the browsers cope up with the code. Now, I've tried it on my code it works. The content is displaying properly in Mozilla, however, it messes up the Javascript that I wrote along with Polymer. I tried two options, the first one

addEventListener('WebComponentsReady', function() {
Polymer({
is: "main-header"
}); });


I did this and there are still error logs on the console while if I wrap the whole script, it wouldn't work as well. Example:

addEventListener('WebComponentsReady', function() {
Polymer({
is: "main-header"
});
// extra code here
});


I think wrapping addEventListener to the whole code is also causing the problem. Any ideas how to fix or are there any other viable options than adding an event listener to the code?

Answer

It looks like using

addEventListener('WebComponentsReady', function() {
});

is messing up my Javascript because it has a conflict with

addEventListener('HTMLImportsReady', function() {
});

I had to remove it in order for the script to work properly.