Skip to content
This repository was archived by the owner on May 19, 2025. It is now read-only.
This repository was archived by the owner on May 19, 2025. It is now read-only.

Sub-property change notifies the other sub-properties #88

@Hunsin

Description

@Hunsin

Description

When Objects binding with firebase-document element, changes in sub properties trigger the other sub-properties observers.

Example code

<body>
  <dom-module id="notify-test">
    <template>
      <b>full name</b>
      <div>first name: [[user.fullName.fName]] <br> last name: [[user.fullName.lName]]</div>
      <b>age</b>
      <div>[[user.age]]</div>
      <button on-tap="changeFullName">notify full name</button>
      <button on-tap="changeLastName">set last name</button>
    </template>
    <script>
      Polymer({
        is: "notify-test",
        properties: {
          user: {
            type: Object,
            value: {
              fullName: {fName: "foo", lName: "bar"},
              age: 30
            },
            notify: true
          }
        },
        observers: [
          "_ageChanged(user.age)"
        ],
        changeFullName: function() {
          this.user.fullName.fName = "xyz";
          this.user.fullName.lName = "opq";
          this.notifyPath("user.fullName", this.user.fullName);
        },
        changeLastName: function () {
          this.set("user.fullName.lName", "abc");
        },
        _ageChanged: function() {
          console.log("age notified!!");
        }
      });
    </script>
  </dom-module>

  <template is="dom-bind" id="app">
    <firebase-app
      api-key="..." auth-domain="..." database-url="..."></firebase-app>
    <firebase-document 
      path="speakers/notify"
      data="{{notify}}"></firebase-document>
    <notify-test user="{{notify}}"></notify-test>
  </template>
</body>

Expected outcome

_ageChanged(user.age) should not be triggered no matter changes in fName or lName.

Actual outcome

_ageChanged is triggered either changes from remote Firebase or client side. If we remove firebase-document, _ageChanged won't be trigger.

Browsers Affected

I've checked on Edge, Opera, Chrome, I believe that others should have same problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions