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
{{ message }}
This repository has been archived by the owner on May 29, 2019. It is now read-only.
The documentation page indicates that I need to use polymer function this.push("fileItems",object) rather than fileItems.push(object), otherwise I need manually call this.$.table_template.render() to update the template.
What happened is, when I append an object to fileItems array, the render() throws an exception
I roughly traced the problem, and find that in function getKey in line 3883 of polymer.html, key = this.omap.get(item); was executed. But this.omap only contains 2 elements (initial value). Therefore, the new appended elements cause key to be undefined and then lead to the exception.
@kevinpschaaf I would expect this to work, but apparently it doesn't. In v.1.2.3, it throws as described in #3018. In v1.1.5, it doesn't throw, but the wrong data is displayed.
You can use the render method to force a dom-repeat to update (for example, if you’re using a third-party library that mutates the array).
Calling the render method is useful for:
Forcing a synchronous render of changes that have occurred to the data (this is normally batched and rendered asynchronously)
Re-running the filter/sort functions on the view due to changes to the filter/sort criteria
The description of any changes to the array that occurred without use of the provided array mutation API must be provided using the public notifySplices method. render() does not provide a substitute for this.
arthurevans
changed the title
calling render() of dom-repeat after mutate the items array causes "Uncaught TypeError: Cannot read property '0' of undefined"
Correct documentation of dom-repeat.render(); add docs for notifySplices
Nov 19, 2015
From @wuyuanyi135 on November 19, 2015 4:47
I was trying to mutate a items array of a dom-repeat with javascript and see if the template will update after the change.
This is my test code, and I host it on c9 on Nov 19, 2015. Hope this helps.
The documentation page indicates that I need to use polymer function
this.push("fileItems",object)
rather thanfileItems.push(object)
, otherwise I need manually callthis.$.table_template.render()
to update the template.What happened is, when I append an object to
fileItems
array, therender()
throws an exceptionI roughly traced the problem, and find that in function
getKey
in line 3883 ofpolymer.html
,key = this.omap.get(item);
was executed. Butthis.omap
only contains 2 elements (initial value). Therefore, the new appended elements causekey
to beundefined
and then lead to the exception.Did i use the proper way to invoke render()? How can I update
this.omap
?Copied from original issue: Polymer/polymer#3022
The text was updated successfully, but these errors were encountered: