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

Potential bug when recycling nested elements #183

Closed
whaaaley opened this issue Jan 28, 2021 · 1 comment
Closed

Potential bug when recycling nested elements #183

whaaaley opened this issue Jan 28, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@whaaaley
Copy link
Contributor

whaaaley commented Jan 28, 2021

I apologize in advance if this is not supported or if I'm just doing something wrong, but I'm getting some inconsistent behavior when toggling some children in my view. When using conditionals in nested element's children, upon recycling, (initial renders are fine), I get a few different errors.

Failed to execute 'removeChild' on 'Node': parameter 1 is not of type 'Node'.
and
Failed to execute 'insertBefore' on 'Node': parameter 2 is not of type 'Node'.
and
Cannot read property 'key' of undefined

h('div', {}, [
  state.foo === false && h('h1', {}, [text('hello')])
])

I have a repro here based on the todo app example in the read me. If you comment/uncomment some of the lines you can see the two different errors in the dev tools.
https://codepen.io/dustindowell/pen/ExNYbQK?editors=1010

In the meantime I'm doing stuff like this as a work around. If this was the "correct" way of doing things, I'm down for it, but some consistency between initial render and recycles might be worth looking into.

const ErrorComponent = props => {
  if (props.show === true) {
    return h('div', {}, [text(props.message)])
  }

  return h('div', { hidden: true }, []) // node placeholder
}
@jorgebucaran jorgebucaran added the bug Something isn't working label Jan 28, 2021
jorgebucaran added a commit that referenced this issue Jan 28, 2021
Forgot to update replaced vnodes in the vdom
while appending children.
@jorgebucaran
Copy link
Owner

jorgebucaran commented Jan 28, 2021

Thanks for the bug report. Your pen now works with 8.1.0. 🎉✨

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants