Skip to content

Commit

Permalink
Allow component re-use
Browse files Browse the repository at this point in the history
Partial fix for hexops#78, only allows re-use of *vecty.Component, not
*vecty.HTML
  • Loading branch information
pdf committed May 7, 2017
1 parent a32ca06 commit 79fb65c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions dom.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,11 @@ func (h *HTML) restoreHTML(prev *HTML) {
continue
}
prevChild := prev.children[i]
prevChildRender, ok := prevChild.(*HTML)
if !ok {
prevChildRender, isHTML := prevChild.(*HTML)
if !isHTML {
prevChildRender = prevChild.(Component).Context().prevRender
}
if nextChildRender == prevChildRender {
if nextChildRender == prevChildRender && (isHTML || prevChild != nextChild) {
panic("vecty: next child render must not equal previous child render (did the child Render illegally return a stored render variable?)")
}
if doRestore(prevChild, nextChild, prevChildRender, nextChildRender) {
Expand Down Expand Up @@ -207,7 +207,7 @@ func (h *HTML) Restore(old ComponentOrHTML) {
}
}

if prev, ok := old.(*HTML); ok && prev != nil {
if prev, ok := old.(*HTML); ok && prev != nil && prev.Node != nil {
if h.text != "" && prev.text != "" {
h.restoreText(prev)
return
Expand Down

0 comments on commit 79fb65c

Please sign in to comment.