Skip to content

Changing a DOM attribute doesn't change the model #246

Closed
@abarth

Description

I'm not sure whether this behavior is expected, but it surprised me. I would expect that setting a DOM attribute would mutate the model value wired up to that attribute, like it does for custom elements.

For the test case below, I see "PASS (2 of 2)" displayed but not "PASS (1 of 2)". That indicates that changing the custom element's attribute mutated the model but that changing a regular element's attribute did not mutate the model.

<!DOCTYPE html>
<script src="../third_party/polymer/polymer.js"></script>
<polymer-element name="test-custom" attributes="value">
  <template>
  </template>
  <script>
  Polymer('test-custom', {
    value: null,
  });
  </script>
</polymer-element>
<polymer-element name="test-flag" attributes="go">
  <template>
    <div id="foo" value="{{ value1 }}"></div>
    <div>{{ value1 }}</div>
    <test-custom id="bar" value="{{ value2 }}"></test-custom>
    <div>{{ value2 }}</div>
  </template>
  <script>
  Polymer('test-flag', {
    value1: null,
    value2: null,
    goChanged: function() {
      this.$.foo.setAttribute('value', 'PASS (1 of 2)');
      this.$.bar.setAttribute('value', 'PASS (2 of 2)');
    },
  });
  </script>
</polymer-element>
<test-flag go="true"></test-flag>

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