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

dom-repeat initial-count throttling fails when pushing new items #5631

Assignees
Labels

Comments

@kevinpschaaf
Copy link
Member

kevinpschaaf commented Feb 18, 2020

Description

When adding new items to an already-rendered <dom-repeat> with initial-count, chunking is re-initialized. This has two effects: First, any already rendered items past the initial count are removed, then because the already-rendered items "render" in a very short time, the average time per item is very low, causing the remainder of the list to be rendered in one shot, thus chunking is defeated for newly added items.

Live Demo

https://glitch.com/edit/#!/kaput-hollyhock-o6tozsgx4a?path=index.html:9:0

Expected Results

  • After adding more items (using either push or spread method), the new items are chunked in.
  • The global id of the initially rendered items do not change (meaning they haven't been removed & re-created)

Actual Results

  • The added items are rendered in one shot.
  • The global id of the initially rendered items change (meaning they were removed & re-created)

Versions

  • Polymer: v3.x
@kevinpschaaf kevinpschaaf self-assigned this Feb 18, 2020
kevinpschaaf added a commit that referenced this issue Feb 21, 2020
* Only restart chunking (resetting the list to the initialCount) if the `items` array itself changed (and not splices to the array), to match Polymer 1 behavior.
* Add `reuseChunkedInstances` option to allow reusing instances even when `items` changes; this is likely the more common optimal case when using immutable data, but making it optional for backward compatibility.
* Only measure render time and throttle the chunk size if we rendered a full chunk of new items. Ensures that fast re-renders of existing items don't cause the chunk size to scale up dramatically, subsequently causing too many new items to be created in one chunk.
* Increase the limit by the chunk size as part of any render if there are new items to render, rather than only as a result of rendering.
* Continue chunking by comparing the filtered item count to the limit (not the unfiltered item count).
kevinpschaaf added a commit that referenced this issue Feb 22, 2020
Fixes for several related dom-repeat chunking issues. Fixes #5631.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment