You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have a use-case here that is probably not typical... so you can tell me to get lost! If nothing else, maybe this will help someone in the future.
Our server sends rendered markup that we want to show within an iron-list... there isn't necessarily any definitive "template". So our list's template contains a custom-element whose role is to render the html received from the server. eg:
Then I think... "ah... I really don't want to innerHTML that markup every time a given item is re-bound". So I turn the markup into an html element:
items = [
{ element: @type HTMLElement }
];
Performance is noticeably imrpoved. - but - I keep hitting some wierd problem: Often times, when scrolling back to the top of the list, the first element is empty. My implementation for the template element is something like this:
class HtmlEcho extends Polymer.Element {
set item(item) {
let p = this.shadowRoot;
while(p && p.firstChild) { p.removeChild(p.firstChild); }
p.appendChild(item.element);
}
After some investigation, it seems that the model was bound to two separate template instances. One of them is the offscreen (translateY(-10000)) items. Since the dom element is appended to that offscreen thing, it was removed from the physical item where it's wanted.
The solution is simple... everyone gets a copy.
p.appendChild(item.element.cloneNode(true));
I thought it might be worth reaching out to the team. The full scope of the backfillItem is beyond my grasp... I may have some of the details here wrong. Should it be given a copy of the model instead of a reference?
The text was updated successfully, but these errors were encountered:
Edit: I realize after posting that a copy of the model for the backfill item wouldn't fix my particular issue since Im doubtful copying an Object would deep copy an html element member.
Some additional questions follow:
Can some property be exposed for a template instance "hey... You're not real". Is the backfill item used for computing metrics at all?
Description
We have a use-case here that is probably not typical... so you can tell me to get lost! If nothing else, maybe this will help someone in the future.
Our server sends rendered markup that we want to show within an iron-list... there isn't necessarily any definitive "template". So our list's template contains a custom-element whose role is to render the html received from the server. eg:
That works fine...
Then I think... "ah... I really don't want to innerHTML that markup every time a given item is re-bound". So I turn the markup into an html element:
Performance is noticeably imrpoved. - but - I keep hitting some wierd problem: Often times, when scrolling back to the top of the list, the first element is empty. My implementation for the template element is something like this:
After some investigation, it seems that the model was bound to two separate template instances. One of them is the offscreen (translateY(-10000)) items. Since the dom element is appended to that offscreen thing, it was removed from the physical item where it's wanted.
The solution is simple... everyone gets a copy.
I thought it might be worth reaching out to the team. The full scope of the backfillItem is beyond my grasp... I may have some of the details here wrong. Should it be given a copy of the model instead of a reference?
The text was updated successfully, but these errors were encountered: