Closed majo44 closed 4 years ago
Related issue https://github.com/developit/preact/issues/654
I found a way to solve this in your variant of preact-custom-element
. Here's the updated bin:
https://www.webpackbin.com/bins/-Ki5qi9RpWySLvOGz6H5
This appears to still be an issue, although I admittedly don't really understand the issue or the use-case for this.
In any case, I've added a test case for this in the test-rerender-root
branch, for anyone who thinks they might have a solution and/or whenever this is solved.
This should be working correctly in Preact X. Please re-open if not!
I do not using shadowDOM
Output is:
This works in this way because when preact is come to patch
<x-c>
is removing children of it.<x-c>
is not a component is regular node for preact, so on second time render preact is removing children of it because vnode do not contains any children, custom-element do not get any livecycle notification so it is not rerender it content again.In other words custom element should control rendering of it by self, not from outside parent.
But this will require some changes in preact eg:
https://github.com/developit/preact/blob/master/src/vdom/diff.js#L128
should be replaced by:
Or more generic like https://github.com/Matt-Esch/virtual-dom/blob/master/docs/thunk.md
Webpack.bin: https://www.webpackbin.com/bins/-Ki44_xg5yie0o-jHaXv