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.

feat: resolve WebComponent constructor within h()

See original GitHub issue

As 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:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
thysultancommented, Jun 1, 2017

Custom Elements also inherit from Node so vnodeName.ELEMENT_NODE === 1 should also work since HTMLElement is not available in the global namespace of ex. Node.js so it might throw when using the renderToString module.

Is HTMLElement the only class Custom Elements can extend?

1reaction
Hotellcommented, May 31, 2017

Sweeeeeeet Christmassss !

Read more comments on GitHub >

github_iconTop 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 >

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