Reputation: 9431
How can I get unpublished Polymer attributes to behave like published attributes?
unpublished obj attribute:
<dynamic-attributes obj="[object Object]"></dynamic-attributes>
published obj attribute:
<dynamic-attributes obj="{{ {'hello':'world'} }}"></dynamic-attributes>
Upvotes: 0
Views: 171
Reputation: 9431
The trick is to grab the attributes before Polymer gets ahold of them. This can be done in the created
lifecycle callback.
It can be used in conjunction with injectBoundHTML
to render
<polymer-element>
<script>
Polymer({
created: function () {
var name = 'seriously-effect-' + this.type;
// get mustache bindings before they get parsed and bound
var instanceDecl = '<' + name + ' ';
var attrs = this.attributes;
for(var i = 0, l = attrs.length, attr; attr = attrs[i], i < l; ++i){
instanceDecl += attr.name + '="' + attr.value + '" ';
}
instanceDecl += '></' + name + '>';
//then parse attributes somehow... and stamp the template
this.templateInstance.model.injectBoundHTML(instanceDecl, parsedAttributesModel);
},
});
</script>
</polymer-element>
Upvotes: 1