I created an element which which I'll simplify here for brevity, and I wanted to do an end-to-end process and see if it works.
This is its bower.json file:
{
"name": "test-element",
"version": "0.0.1",
"authors": [
"my name"
],
"description": "A description",
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"dependencies": {
"polymer": "~0.9.0"
}
}
I uploaded it to my test repo, and opened a new project in WebStorm.
I did bower install test-element and it also downloaded the polymer directory which is the dependency, as I wanted, though there are no js files there. (Shouldn't there be a polymer.js file to reference?)
Now, my index file that loads has this in the body:
<script src="bower_components/webcomponentsjs/webcomponents.js"></script>
<link rel="import" href="bower_components/test-element/test-element.html">
<test-element
elements="[...array contents...]">
</test-element>
And my test-element.html:
<link rel="import" href="../../../polymer/polymer.html">
<polymer-element name="test-element" ....>
<template>
... doesn't really matter ...
</template>
<script>
Polymer({
created: function () { .. }
});
</script>
</polymer-element>
But when I load the page I see this in the console:
Uncaught SyntaxError: Failed to execute 'registerElement' on 'Document': Registration failed for type 'undefined'. The type name is invalid.
I tried many posts, and I can't see what I'm missing here. I'm loading the webcomponents.js before importing the element's HTML file.
So 2 questions:
- Why does this error occur and what did I do wrong? Am I missing the
polymer.js? If so, why didn't it download as part of the dependency ? - If I have many elements, do I need to include the
polymer.htmlin each of them or can I just load it once in theindex.htmlfile?