Skip to content
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

Ability to use web-components as component #230

Closed
saivishwak opened this issue Apr 2, 2023 · 5 comments
Closed

Ability to use web-components as component #230

saivishwak opened this issue Apr 2, 2023 · 5 comments

Comments

@saivishwak
Copy link

saivishwak commented Apr 2, 2023

If we have a web component its naming spec says that the name should not start with a Captial letter. Due to this the ability to use web-components as components is restricted.

Can we extend the component naming spec to support web-components? This will give us the ability to embed web components in solid js components.

example -

<div>
   <cusomt-component title={"hello"}/>
</div>

Web component naming spec - https://html.spec.whatwg.org/#valid-custom-element-name

Thank You

@saivishwak
Copy link
Author

@ryansolid
Copy link
Owner

I'm confused by the ask. Custom elements(webcomponents) are native elements so they should already work today by using all lowercase. Web Components aren't JSX components so they should fail that check. JSX components are just functions whereas web components are registered as part of the native platform.

Other tooling including TypeScript relies on this capitalization heuristic in terms of naming what is a component or not.

@saivishwak
Copy link
Author

saivishwak commented Apr 3, 2023

I was trying to add web components directly in solid code and now if the web components props are tied to any signal it still does not auto update the prop internally as the compiled output does not handle this scenario.

After some research found out the way solid element is handling this, via creating signals for props and passing in an object with getter and setter to access the signal.

const [count, setCount] = createSignal(0);
return (
<div>
   <web-component title={count()}></web-component>
</div>
)

In this example when count changes the web-component does not reflect the changes. Not sure if this is what SolidJS should handle as it might be out of context from its perspective.

@ryansolid
Copy link
Owner

If you have a web component that updates in response to props or attribute changes the internal mechanism doesn't have to be Signals. Solid will make sure that on signal value outside we update those properties, but your webcomponent should be able to handle those changes itself. If it doesn't watch properties you can prefix with attr: which will force attributes. See if that works for you.

@saivishwak
Copy link
Author

Yes, Internal Mechanism of prop updates are handled at web components. The outside world props changes were reflected using signals.

Thanks for the clarification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants