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

Properties not cleared when elements reused in dom-repeat. #3288

Closed
kevinpschaaf opened this issue Jan 13, 2016 · 3 comments
Closed

Properties not cleared when elements reused in dom-repeat. #3288

kevinpschaaf opened this issue Jan 13, 2016 · 3 comments

Comments

@kevinpschaaf
Copy link
Member

From @kayur on December 24, 2015 8:36

I'm trying to use dom-repeat to create a list of paper buttons, which have a custom attribute that I set. The html template for the custom element is a bit complicated but here is an example that illustrates the core issue:

<dom-module id="my-element">
  <template>
    <template is="dom-repeat" items="[[experiments]]">
      <paper-button label$="[[item.name]]">
        [[item.name]] the [[item.job]]
      </paper-button>
    </template>
  </template>
  ...

<my-element> has an property experiments which gets updated frequently with new data. experiments is used to generate a list of <paper-button> with a custom attribute label that's set to item.name.

Let's set experiments = [{ name: "joe", job: "plumber"}, { name: "cat", job: "maker"}]

Let's call the first paper button, button. I would expect button.getAttribute(label) === joe and button.label === undefined. That's not the case. Some magic sets button.label to joe. That's fine. It could be useful magic.

Now let's set experiments = [{name: "cat", job: "maker"}]. I would expect button.getAttribute(label) === cat, and indeed that's correct. But button.label === joe.

Why is this happening?

It feels like a bug because I'd expect reused elements not have zero state that indicates they were used for anything else before.

Here is a jsbin with this example:
http://jsbin.com/hetazocaye/6/edit?html,js,console,output

Strangely div does the right thing.
http://jsbin.com/rekavifozu/3/edit?html,js,console,output

Copied from original issue: PolymerElements/paper-elements#62

@kevinpschaaf
Copy link
Member Author

Yes, this looks like a bug with the data configuration process Polymer uses to efficiently flow binding data to other Polymer elements at initial construction of the tree. It incorrectly passes attribute bindings as property data. This should be trivial to fix, such that the label property is always undefined in your paper-button example: http://jsbin.com/gonola/edit?html,console -- I assume this is what you would expect, yes?

@kayur
Copy link

kayur commented Jan 21, 2016

Yes, that is what I would expect.

@sorvell sorvell closed this as completed in 246ea72 Feb 4, 2016
sorvell pushed a commit that referenced this issue Feb 4, 2016
Exclude attribute bindings from configuration. Fixes #3288.
sorvell pushed a commit that referenced this issue Feb 6, 2016
Configure attr's with property effects. More robust fix for #3288.
@jfrazzano
Copy link

Will this have a carry-over affect on the "for" property in the label. I just was wondering if the prop to atts initial config was intentional to keep the for attribute inline with the with the label and related input. I have been doing a lot of input work, so this could be an "over thinking moment on my part" but a similar issue happened with a paper-input fix a few weeks ago, so i thought it better to say something than just shhhh....

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

4 participants