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
Non browser environments #108
Comments
I’ve been thinking about this as well. I’m not sure what the best approach is to be honest. I actually had it on my radar to dive into both Lit’s SSR and Astro today. Let me mess around with it a bit and see if I can come up with an approach that feels good. I’d also be happy to chat here about it or field a PR but don’t want to just accept the first possible solution. |
I added a PR to Lit's |
@ericponto are you using the I'm not sure about other environments, but I'm hoping that support for internals can be added to those environments longer term to ensure proper ARIA mechanics. |
We are using @lit-labs/react and then doing SSR with Next.js. So it isn't rending the shadow dom or anything server side, just the outer WC tags and their attributes. |
Got it. Well, the above PR will solve this issue, given the following input customElements.define('lit-internals', class extend LitElement {
constructor() {
super();
const internals = this.attachInternals();
internals.role = 'widget';
}
render() {
return html`<h1>Hello <slot>world</slot></h1>`;
}); and <lit-internals>y'all</lit-internals> it will output the following before hydration <lit-internals role="widget">
<template shadowroot="open">
<h1>Hello <slot>world</slot></h1>
</template>
y'all
</lit-internals> I'll leave this issue open until Lit's SSR package either accepts my (or a similar PR) or decides they don't want to support this use case and I can write alternative documentation here. |
We have run into a similar issue with this polyfill around |
I don’t think it would. I can take a stab at cleaning some of that up. Good call out. |
OK, 1.2.6 will check if At the very least I'd like attribute hydration for the ARIAMixin stuff and no errors thrown :D |
Also seeming to run into the following with the latest version of the polyfill loading Lit in Next.js:
Not sure if that is something you'd expect Lit SSR shim to handle though? I can open an issue over there if so. |
Ideally none of the polyfill should run on the server. I just don’t know a reliable way to check if the polyfill should run. |
Ah I see, could you potentially expose an entry point that isn't an IIFE? So for example in Lit projects, the polyfill could be conditionally initialized after checking the EDIT: I guess this would still potentially cause compilation failures. |
This should work in |
We would like to include this polyfill with our Lit components we are building that use element internals. This makes it very easy for consumers of the component to have a single import and not have to worry about polyfilling. However, we import these components in a server-side rendering setup and this polyfill runs and tries to instantiate a new MutationObserver, which causes it to break.
We'd really like to not have to separate the import of the component from the import of the polyfill.
I'd be willing to submit a PR to address this, but would like feedback on posssible solutions.
typeof window !== "undefined"
)exports
field in the package.json to point to a different noop version fornode
vs. thedefault
The text was updated successfully, but these errors were encountered: