notwaldorf / ama

:raising_hand: Ask @notwaldorf anything!
94 stars 13 forks source link

Bug in dom-repeat filter functions? #99

Closed gauvins closed 6 years ago

gauvins commented 6 years ago

Hi Monica,

Thanks for all you do for Polymer, you're a great spokesperson and I really enjoyed your work/code and learned a lot from your work.

One thing I'd like to ask is if there is a bug in the dom-repeat filter functions. I've been experiencing some strange behaviour with these functions that I did not expect. I'm using a dom-repeat to render a set of Card objects in a Polymer app. The items that make up the data for the cards are a set of Firebase RTDB docs that I'm getting using a simple firebase-query. These are posts that different users create, and I display them in a list using dom-repeat to create them. To show only your own posts I filter the posts using the dom-repeat filter function to test if the id of the post is the same as the user id. This all works, but when I added a counter property to be incremented to show the number of posts a user has, things got weird. If a user had 2 posts the counter would show 10 or 12 randomly. I put a breakpoint on the counter and saw that Polymer is calling the filter function 5 or 6 times! That made the counter property completely wrong, but what's worse, I have no idea why Polymer is calling the filter function this many times? I've looked at the data coming from the firebase-query, and it's correct, but is being passed to the dom-repeat 5 or 6 times, but the UX of the app only shows 2 Cards rendered correctly. What is going on here???

Thanks for your support =) Simon

notwaldorf commented 6 years ago

This sounds like a bug report, so you should file that on the Polymer repo instead (with reproducible code, ideally) :)