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

TypeError when updating a sub-property: Cannot use 'in' operator to search for 'value' in undefined #3307

Closed
justincy opened this issue Jan 19, 2016 · 11 comments

Comments

@justincy
Copy link

I'm getting a TypeError when attempting to update a sub-property:

Cannot use 'in' operator to search for 'value' in undefined
  TemplateInstance.Polymer.Templatizer._notifyPathUpImpl [as _notifyPathUp] at /components/polymer/polymer.html:3758
  TemplateInstance.Polymer.Base._addFeature._notifyPath at /components/polymer/polymer.html:2044
              TemplateInstance.<anonymous> at /components/polymer/polymer.html:1562
  TemplateInstance.Polymer.Base._addFeature._notifyListener at /components/polymer/polymer.html:2016
             trepo-core-person.<anonymous> at /components/polymer/polymer.html:1588
  trepo-core-person.Polymer.Base._addFeature.fire at /components/polymer/polymer.html:1335
  trepo-core-person.Polymer.Base._addFeature._notifyPathUp at /components/polymer/polymer.html:2208
  trepo-core-person.Polymer.Base._addFeature._notifyPath at /components/polymer/polymer.html:2044
  trepo-core-person.Polymer.Base._addFeature.set at /components/polymer/polymer.html:2100
                                 <unknown> at /components/trepo-core-person/trepo-core-person.html:173

The last line in the stack trace, trepo-core-person.html:173, looks like this:

self.set('value.id', personResponse.body.id);

I have verified that value exists as an empty object {} and personResponse.body.id has a value.

This is only happening when running tests with wct. It's using Polymer v1.2.3.

@justincy
Copy link
Author

This error only occurs when using test-fixture. It appears that the _parentProps is not being set properly when the template is processed and the element is stamped into the DOM. Then when the notification for the sub-property change is processed it blows up.

Everything works as intended if I don't use test-fixture.

@justincy
Copy link
Author

This also only happens if the sub-property's root value is bound inside the text-fixture, such as:

  <test-fixture id="element">
    <template is="dom-template">
      <my-element data="{{data}}"></my-element>
    </template>
  </test-fixture>

@dfreedm
Copy link
Member

dfreedm commented Jan 27, 2016

This seems more like an issue with test-fixture not handling data binding. @cdata, thoughts?

@cdata
Copy link
Contributor

cdata commented Feb 5, 2016

I concur that this may be related to a test-fixture problem, although I would also like to see a reduced test case so that we can actually explore the problem directly. @justincy would you be willing to provide a JSBin?

@justincy
Copy link
Author

justincy commented Feb 5, 2016

Sorry but I'm not involved with that code at the moment. Plus I stated earlier that is only occurs when using wct from the cli. I can't remember whether that's true, but if it is then jsbin isn't going to help.

@Sleeckx
Copy link

Sleeckx commented Feb 11, 2016

@cdata, I encountered the same issue and managed to produce a small test-case without wct:

http://jsbin.com/dunikitije/edit?html,console,output

The issue is fixed when I change the test property binding on <my-child> from two-way to one-way.
As in: <my-child test="[[test]]"></my-child>

@cdata
Copy link
Contributor

cdata commented Feb 11, 2016

@Sleeckx Thanks for the research. But, if you don't use test-fixture in your test case, I think that the source of the issue is still inconclusive.

@Sleeckx
Copy link

Sleeckx commented Feb 12, 2016

@cdata, I respectfully disagree. As @justincy said in his last comment:

I stated earlier that is only occurs when using wct from the cli. I can't remember whether that's true

Also, if it only occurred while they were using test-fixture it is still no guarantee that the component ever called set or notifyPath in normal use cases. Or, more importantly, that my-element was at any time wrapped in a dom-template when not using test-fixture.

From what I saw, the issue is mainly related to the fact that calling set('xxx' or notifyPath('xxx' on the element causes the two-way binding to fire a xxx-changed, which gets bubbled to the dom-template, which in turn incorrectly assumes that it has the _parentProps field set on the template instance.

@Ortham
Copy link

Ortham commented Feb 12, 2016

I'm also getting this error when trying to bind the opened attribute of a <paper-menu-button> to an item in an <iron-list> (which uses the Templatizer behaviour). For example:

  <iron-list id="list">
    <template>
      <div>
        [[item.name]]
        <paper-menu-button opened="{{item.isMenuOpen}}">
          <paper-icon-button icon="more-vert" class="dropdown-trigger"></paper-icon-button>
          <paper-menu class="dropdown-content">
            Bar
          </paper-menu>
        </paper-menu-button>
      </div>
    </template>
  </iron-list>
  <script>
    const items = [{
      name: 'foo',
      isMenuOpen: false,
    }];
    document.getElementById('list').items = items;
  </script>

Clicking on the button displays the menu, but also logs the reported error to the console. Clicking on the displayed menu also logs the reported error to the console.

@cdata
Copy link
Contributor

cdata commented Feb 12, 2016

@Sleeckx He also said:

This error only occurs when using test-fixture.
Everything works as intended if I don't use test-fixture.

Even if the bug is not related to test-fixture, I would like the reporter to restate the issue in an actionable way and provide a reduced test case. Thank you!

@TimvdLippe
Copy link
Contributor

Thanks for the issue. It has been a great while since this issue was opened. Sadly, this issue misses a live reproduction with Polymer 2 for us to be able to debug and potentially fix. Polymer 2 fixes a large amount of issues, probably including this one as well.

Please see CONTRIBUTING.md for guidelines on filing issues. You can start from this jsBin template as a starting point and link it in the issue template under "Live Demo".

Feel free to file a new issue following these instructions if you can still reproduce this issue with Polymer 2. Thank you!

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

7 participants