question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Preact and custom elements

See original GitHub issue

Hello, I have a native custom element, lets call it <custom-video-player>. It handles its own children. The children can be a <video> or an <image> for example. Unfortunately preact clobbers the child dom that I create in my createdCallback and the entire component breaks. Is there an option I can pass in to make preact accept the component as it is and not traverse its children? I am guessing this is related/identical to #39

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
developitcommented, Nov 15, 2016

This is fixed in version 7. npm I preact@beta. Also I believe it only affects polyfilled custom Elements.

0reactions
oskborcommented, May 13, 2017

Hi, I didn’t need to do anything more, but also I didn’t use shadow dom in my component. I no longer have access to that code base, so I can’t dig into it any more. Sorry I couldn’t be more helpful

On Sat, May 13, 2017, 18:30 Tom notifications@github.com wrote:

Hi @oskbor https://github.com/oskbor – I’m running into a similar issue you described (mine is #344 https://github.com/developit/preact/pull/344). So my custom elements are rendering as-expected on initial page render, but when navigating to subsequent views (in a SPA etc), they stop updating.

They also maintain their own internal nodes, and after inspecting the nodes it seems like there contents have been wiped out. Seems like Preact is breaking the shadow dom for custom elements.

Wondering if you had to do anything in addition to get this working aside from just bumping preact version? I’ve tried the latest versions and still running into issues. 😦

Any input much apprecaited.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/developit/preact/issues/405#issuecomment-301258993, or mute the thread https://github.com/notifications/unsubscribe-auth/ABPNfX-NZAospyvvnB6UPk8TPuV7k5LLks5r5dq8gaJpZM4KyUv0 .

Read more comments on GitHub >

github_iconTop Results From Across the Web

Web Components | Preact
Custom Elements generally rely on custom properties in order to support setting complex values that can't be expressed as attributes. This works well...
Read more >
preactjs/preact-custom-element - GitHub
preact -custom-element. Generate/register a custom element from a preact component. As of 3.0.0, this library implements the Custom Elements v1 spec.
Read more >
Custom elements and Preact - James Hill
Custom elements and Preact ... Preact is a fantastic fit for bringing the power of a virtual DOM, and JSX, to existing projects....
Read more >
How to use Web Components in Preact and TypeScript
Web Components are created using a combination of several stand-alone technologies such as Custom Elements, Shadow DOM, and HTML templates.
Read more >
preact-custom-element examples - CodeSandbox
Learn how to use preact-custom-element by viewing and forking preact-custom-element example apps on CodeSandbox.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found