summaryrefslogtreecommitdiff
path: root/packages/integrations/lit/server.js
diff options
context:
space:
mode:
authorGravatar Matthew Phillips <matthew@skypack.dev> 2022-06-21 08:32:05 -0400
committerGravatar GitHub <noreply@github.com> 2022-06-21 08:32:05 -0400
commitf5afaf24984ee7d4d6e908a7eeed17f5ca18c61e (patch)
tree68cb423edc44774f6ffecd2e860c41439c653756 /packages/integrations/lit/server.js
parent411af7ae4b0435d740a25fd645380e5bd3949d3a (diff)
downloadastro-f5afaf24984ee7d4d6e908a7eeed17f5ca18c61e.tar.gz
astro-f5afaf24984ee7d4d6e908a7eeed17f5ca18c61e.tar.zst
astro-f5afaf24984ee7d4d6e908a7eeed17f5ca18c61e.zip
Support re-exporting astro components containing client components (#3625)
* Support re-exporting astro components containing client components * Include metadata for markdown too * Fix ssr, probably * Inject post-build * Remove tagName custom element test * Allows using the constructor for lit elements * Fix hoisted script scanning * Pass through plugin context * Get edge functions working in the edge tests * Fix types for the edge function integration * Upgrade the compiler * Upgrade compiler version * Better release notes for lit * Update .changeset/unlucky-hairs-camp.md Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com> * Properly test that the draft was not rendered * Prevent from rendering draft posts * Add a changeset about the build perf improvement. Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com>
Diffstat (limited to 'packages/integrations/lit/server.js')
-rw-r--r--packages/integrations/lit/server.js8
1 files changed, 7 insertions, 1 deletions
diff --git a/packages/integrations/lit/server.js b/packages/integrations/lit/server.js
index 05f0d1f9d..df284dbeb 100644
--- a/packages/integrations/lit/server.js
+++ b/packages/integrations/lit/server.js
@@ -9,6 +9,8 @@ function isCustomElementTag(name) {
function getCustomElementConstructor(name) {
if (typeof customElements !== 'undefined' && isCustomElementTag(name)) {
return customElements.get(name) || null;
+ } else if(typeof name === 'function') {
+ return name;
}
return null;
}
@@ -24,7 +26,11 @@ async function check(Component, _props, _children) {
return !!(await isLitElement(Component));
}
-function* render(tagName, attrs, children) {
+function* render(Component, attrs, children) {
+ let tagName = Component;
+ if(typeof tagName !== 'string') {
+ tagName = Component[Symbol.for('tagName')];
+ }
const instance = new LitElementRenderer(tagName);
// LitElementRenderer creates a new element instance, so copy over.