I am trying to create an element with attributes that will indicate which element should consist of this element.
I have a flip element of a 3d map, which I use for this purpose in index.html, which is defined as:
<html>
<head>
<script src="bower_components/webcomponentsjs/webcomponents.js">
</script>
<link rel="import" href="elements/general-element.html">
</head>
<body>
<general-element
name="card-flip"
address="elements/card-flip.html">
<front>
FRONT
</front>
<back>
BACK
</back>
</general-element>
</body>
</html>
It is indicated by general-element.html:
<link rel="import"
href="../bower_components/polymer/polymer.html">
<polymer-element name="general-element" attributes="name address">
<template>
<div id="element_here">
</div>
</template>
<script>
function addElementToDOM( element_name, _that ) {
var elem = _that.shadowRoot.querySelector( "#element_here" );
add_elem = document.createElement( element_name );
elem.appendChild( add_elem );
}
Polymer ( 'general-element', {
ready: function() {
if (
( this.address != undefined ) &&
( this.name != undefined ) ) {
Polymer.import(
[this.address],
addElementToDOM( this.name, this )
);
}
}
} );
</script>
</polymer-element>
WARNING: the output is empty with an error in the console indicating that the attributes on the flip card were data-bound before updating the Polymer element. This can lead to incorrect binding types.
Can this be achieved in any way?
source
share