Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Templatizer - exception when notifying two-way binding #3196

Closed
tpluscode opened this issue Dec 14, 2015 · 6 comments
Closed

Templatizer - exception when notifying two-way binding #3196

tpluscode opened this issue Dec 14, 2015 · 6 comments

Comments

@tpluscode
Copy link

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?

@bedeoverend
Copy link

FYI this looks like it's related to / duplicate of #3307 and #3422

@tpluscode
Copy link
Author

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.

@tpluscode
Copy link
Author

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?

@tpluscode
Copy link
Author

Hi. Is there any chance for a fix? Or any ideas for a possible hack?

@tjsavage tjsavage added the 1.x label Sep 8, 2016
@stale
Copy link

stale bot commented Mar 13, 2020

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.

@stale stale bot added the wontfix label Mar 13, 2020
@stale
Copy link

stale bot commented Apr 16, 2022

This issue has been automatically closed after being marked stale. If you're still facing this problem with the above solution, please comment and we'll reopen!

@stale stale bot closed this as completed Apr 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants