feat: resolve WebComponent constructor within h()
See original GitHub issueAs you know https://github.com/skatejs/skatejs 5.x is using Preact as default renderer ( we switched from Incremental DOM )
What would be awesome, is to add support for resolving custom-elements constructors within h
so we can provide functionality like in v4:
import {
h, // h is re-exporeted Preacts h
Component // skate WebComponent composed mixin
} from 'skate'
import { MyUserCard } from './web-components'
import { store } from './store'
class MyCmp extends Component {
static get is(){ return 'my-cmp' }
connectedCallback(){
this.data = store.get('user')
}
renderCallback(){
return (
<div>
<h1>Hello World</h1>
<MyUserCard user={this.data} />
</div>
)
}
}
window.customElements.define( MyCmp.is, MyCmp )
so <MyUserCard user={this.data} />
will be recognised by h
that it’s a custom element and will output -> <my-user-card></my-user-card>
This feature would also add better support to raw WebComponents which as win win for everyone #useThePlatform
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:9 (2 by maintainers)
Top Results From Across the Web
WebComponent that extends HTMLButtonElement is not ...
I'm trying to create a web component button but when I add it in HTML the constructor() function is never being called.
Read more >Using custom elements - Web Components | MDN
We don't use constructor() because an element's attributes are unavailable until connected to the DOM. // Create a shadow root this.attachShadow ...
Read more >Lifecycle - Lit.dev
Requests an asynchronous update using the requestUpdate() method, so when a Lit component gets upgraded, it performs an update immediately.
Read more >The custom element constructor did not produce the ... - GitHub
I'm running into trouble getting a simple web component to work when transpiled to ES5. It appears to function perfectly fine under Chrome,...
Read more >All the Ways to Make a Web Component - Feb 2022 Update
Compare coding style, bundle size and performance of 61 different ways to make a Web Component.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Custom Elements also inherit from Node so
vnodeName.ELEMENT_NODE === 1
should also work sinceHTMLElement
is not available in the global namespace of ex. Node.js so it might throw when using therenderToString
module.Is
HTMLElement
the only class Custom Elements can extend?Sweeeeeeet Christmassss !