Hi. I've created a sample plunk as an example of using Templatizer. I added two-way binding and it works, but the console logs message TypeError: Cannot use 'in' operator to search for '{prop}' in undefined. Do I somehow use Templatizer the wrong way?
FYI this looks like it's related to / duplicate of #3307 and #3422
I've bumped into this again and after some more digging, I've found that this problem occurs only when a templatized template is inserted to DOM outside a Polymer element. For example this will work fine:
<dom-module id="a-test">
<template>
<template id="templatizeThis"></template>
</template>
<script>
Polymer({
behaviors: [ Polymer.Templatizer ],
attached: function() {
this.templatize(this.$.templatizeThis);
}
});
</script>
</dom-module>
but this will not (assuming template#templatizeThis is added to document and not import)
<template id="templatizeThis"></template>
<dom-module id="a-test">
<template>
</template>
<script>
Polymer({
behaviors: [ Polymer.Templatizer ],
attached: function() {
var templatizeThis = document.getElementById('templatizeThis')
this.templatize(templatizeThis);
}
});
</script>
</dom-module>
The problem also doesn't occur if the templatized templates are created to another custom element's DOM, which is how I use them.
Okay, I think I got it. The error is thrown on this line, because _parentProps is undefined.
It is only ever set while annotations are being processed during element registration. With any ad-hoc template (also added to Light DOM inside Polymer element), that routine is never called.
The call tree is desugar -> registerCallback -> ensureRegisterFinished -> _ensureRegisterFinished -> _finishRegisterFeatures -> _prepAnnotations -> _processAnnotations.
Would it be possible to ensure templatized templates are similarly processed when they are first used to ensure annotations are processed?
Hi. Is there any chance for a fix? Or any ideas for a possible hack?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Most helpful comment
Hi. Is there any chance for a fix? Or any ideas for a possible hack?