Skip to content

Commit

Permalink
Allow component re-use
Browse files Browse the repository at this point in the history
  • Loading branch information
pdf committed Jan 28, 2017
1 parent 34ae770 commit 22146ed
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion dom.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ func (h *HTML) restoreHTML(prev *HTML) {

// TODO better list element reuse
for i, nextChild := range h.children {
nextChildRender := doRender(nextChild)
if i >= len(prev.children) {
nextChildRender := doRender(nextChild)
if doRestore(nil, nextChild, nil, nextChildRender) {
continue
}
Expand All @@ -171,6 +171,11 @@ func (h *HTML) restoreHTML(prev *HTML) {
if !ok {
prevChildRender = prevChild.(Component).Context().prevRender
}
if c, isComponent := nextChild.(Component); isComponent && prevChild == nextChild {
Rerender(c)
continue
}
nextChildRender := doRender(nextChild)
if nextChildRender == prevChildRender {
panic("vecty: next child render must not equal previous child render (did the child Render illegally return a stored render variable?)")
}
Expand Down

0 comments on commit 22146ed

Please sign in to comment.