Closed wereHamster closed 10 years ago
This is as designed. Updating the ref (either directly or via binding) won't affect existing instances (i.e. "re-render"). If this was working before, it was accidental. I understand this might be convenient, but it opens a box of worms we're not prepared to deal with.
There is an ugly workaround for that problem, but I'd still prefer if it TemplateBinding did this automatically.
<polymer-element name="template-ref" attributes="ref content">
<template>
<template ref="{{ ref }}" bind="{{ m }}"></template>
</template>
<script>
Polymer("template-ref", {
refChanged: function() {
// Create a new object so that polymer re-renders the template
// with the new ref.
this.m = { content: this.content }
}
});
</script>
</polymer-element>
Reconsidering this...
So I think the behavior of a bound ref would be that when/if the referenced template changes, all instances are destroyed and new instances are created using the newly referenced template content
Ok. This is now implemented as of: https://github.com/Polymer/TemplateBinding/commit/2799341
I expect to see 'success' but nothing appear on the page. TemplateBinding only re-renders the template when
bind
,repeat
orif
change. But there doesn't seem to be a corresponding observer on theref
attribute.