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

[labs/ssr] Add localName to DOM emulation for SSR #3375

Open
1 task done
calebdwilliams opened this issue Oct 18, 2022 · 3 comments · May be fixed by #4553
Open
1 task done

[labs/ssr] Add localName to DOM emulation for SSR #3375

calebdwilliams opened this issue Oct 18, 2022 · 3 comments · May be fixed by #4553

Comments

@calebdwilliams
Copy link
Contributor

Should this be an RFC?

  • This is not a substantial change

Which package is this a feature request for?

SSR (@lit-labs/ssr)

Description

When running the SSR script the element's localName and tagName are not added to the element. This has lead to a bug in the ElementInternals polyfill at this line.

This line exists to make sure that the node being referenced by the internals object is a custom element. This might be useful server-side behavior so that elements using AriaMixin via the ElementInternals spec can sprout attributes on their hosts (yet to be tested).

Alternatives and Workarounds

A current workaround for the polyfill has already been implemented, returning an empty object for the internals instance in case no localName is present.

@willmartian
Copy link

Hi, I would love to try and help if this is open to external contributors.

@justinfagnani, is this just a matter of adding the localName field when initializing the ElementRenderer, or is it deeper than that? https://github.com/lit/lit/blob/main/packages/labs/ssr/src/lib/element-renderer.ts#L49

@justinfagnani justinfagnani changed the title Add localName to DOM emulation for SSR [labs/ssr] Add localName to DOM emulation for SSR Mar 8, 2023
@justinfagnani
Copy link
Collaborator

@willmartian sorry for the delayed response. We're definitely open to external contributors (and would love to erase even the external distinction over time). That's one reason I tagged this as a "Good First Issue".

I think what's needed is to implement a .localName getter on Element and to get the tag name of the element from the custom elements registry in the constructor with new.target. We don't have to worry about upgrades on the server.

@Rishab49
Copy link

Rishab49 commented Apr 2, 2023

after making the required changes how can i test it?

kyubisation added a commit to kyubisation/lit that referenced this issue Feb 20, 2024
…lements.define call

This change extends the CustomElementRegistryShim to patch localName and tagName into the web component, when calling define.
This allows instances to call `this.localName` and `this.tagName` accordingly.

Fixes lit#3375
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 📋 Triaged
Development

Successfully merging a pull request may close this issue.

4 participants