-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Preact + Custom Element Side Effects #39
Comments
@c58 - very interesting. Have you tried this with the beta version? (Currently To help me investigate, what are you seeing happen - for example: do the web components get instantiated, but their attributes are not set? Thanks! |
@developit unfortunately, 3.0.1 does not work too. In |
Perfect, will take a look. Will be interesting to see if this is related to Shadow DOM polyfills. |
@developit i've fixed minor mistake in the example. The issue is still there. |
It looks like the way Onsen instantiates CustomElements.js (from the Polymer project) is causing it not to use Shadow DOM at all. This means things like |
The same thing happened with mithril. About re-rendering: with react no issues at all. I have tried to change a content in ons-page and ons-toolbar – content re-rendered as expected.
|
@c58 I came up with a test that shows that React behaves the same way after initial render. The reason Preact and Mithril both remove However, this means that changing the structure of the DOM using React will still cause issues. Really this boils down to what Preact (and React) are designed for: they are designed to constantly morph the DOM into a known state. You simply specify the desired DOM structure, and the work of mutating the DOM to look correctly is done for you. I've published my React example to a fork for you to look at, it shows that after 1s a DOM structure change within I'm definitely still open to working on this, but I think the issue here is a lot more specific than Web Components: It's specifically integrating VDOM libraries with code that expects to be able to destructively mutate the DOM. You can see a fairly complex example of how to account for this if you view the source of preact-mdl. Essentially, there is a wrapper placed around |
Yes, you are right, it does not work :( UPDATE: |
On the positive side, thanks for letting me know about Onsen :) I'm testing out Polymer + Preact as well to see if there are issues. |
Closing for now, will revisit. |
Hey there, running
|
Hi @tconroy - would you be able to open a new issue in the preact-compat repo with a few details of your setup? It doesn't seem related to this issue, since side effects have been fully supported in Preact since 6.x. |
@developit Sure thing. Apologies, I should have posted there first. Hoping to get this resolved :) |
Looks like the 'renders once, subsequent renders don't work' issue remains whether or not preact-compat is present :-S. I'm running:
After switching routes, the element (paper-input, vaadin-grid in this case) is still there in DOM (all attributes intact), but shady DOM is toast (as to why my setup defaults to shady dom despite browser support... ¯_(ツ)_/¯ ). |
@H-Plus-Time I'm having a similar experience. FWIW my components are using the v1 spec ( not v0 ). @developit -- is there any info I/we can provide to make debugging this easier/simpler? |
this might come down to removing component recycling, which is already likely to happen for other reasons. preact just creates DOM elements via createElement(), there's no special behavior for WC's so there isn't really a place to workaround. I'll try to ping you when I have something published without component recycling. |
Sounds good @developit! I have a strong feeling that that is the issue -- although unfortunately my knowledge of web components is a bit limited. If you would like me to test out a pre-release version to see if it fixes the issue on my end toss me a message and I'd be more than happy to report my findings. Cheers! |
Remove unused toVNode function
- Try to mimic the Preact TSD. - Example usage with `noImplicitAny` enabled: import { render } from "preact-render-to-string"; - No idea if I've done it right but it seems to compile and hopefully someone more knowledgeable can build on this.
Hi!
I'm trying to use Preact as React replacement in my mobile app. But it seems that Preact does not support Web Components used inside "render". Web Components is used from OnsenUI framework.
I think that i know why it does not work. Preact uses vdom-dom diffing algorithm, React uses vdom-vdom. Onsen's web components changes a DOM (trying to change) and Preact is thinking that it is not right and it's deny it.
Is there any solution with Preact?
Thanks.
The text was updated successfully, but these errors were encountered: