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

<propertyName>Changed may get called twice for a single property value change #298

Closed
frankiefu opened this issue Sep 27, 2013 · 0 comments

Comments

@frankiefu
Copy link
Member

When you run the below code you will see x-bar's valueChanged() is being called twice. Debugging shows that in instance/properties.js, this._observeNames has ["value", "value"], and that causing it to register 2 observers on the same property. I believe the root cause is in declaration/properties.js, optimizePropertyMaps() simply concats base's observeNames and this observeNames, and doesn't remove duplicates.
https://github.com/Polymer/polymer/blob/master/src/declaration/properties.js#L25

<polymer-element name="x-foo" attributes="value">
  <script>
    Polymer('x-foo', {
      value: null,
      valueChanged: function() {
      }
    });
  </script>
</polymer-element>

<polymer-element name="x-bar" extends="x-foo">
  <script>
    Polymer('x-bar', {
      valueChanged: function() {
        console.log('x-bar valueChanged:', this.value);
      }
    });
  </script>
</polymer-element>

<x-bar></x-bar>

<script>
  document.addEventListener('WebComponentsReady', function() {
    document.querySelector('x-bar').value = {};
  });
</script>

output:

x-bar valueChanged: Object {}
x-bar valueChanged: Object {} 

p.s. This issue is only happening in master branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant