From ec38a8921f02a275949abcababe1b8afdf8184a2 Mon Sep 17 00:00:00 2001 From: Elliott Marquez <5981958+e111077@users.noreply.github.com> Date: Mon, 6 Feb 2023 17:01:21 -0800 Subject: [PATCH] [Lit] add `client:only` functionality to Lit integration (#6111) * [Lit] add `client:only` functionality to Lit integration * add changeset * update lit changeset to minor --- .changeset/good-wolves-remain.md | 6 ++ .../src/components/ClientOnlyComponent.js | 9 ++ .../lit-component/src/pages/index.astro | 8 ++ packages/astro/e2e/lit-component.test.js | 21 +++++ .../src/runtime/server/render/component.ts | 1 + packages/integrations/lit/src/client.ts | 91 +++++++++++++++---- 6 files changed, 116 insertions(+), 20 deletions(-) create mode 100644 .changeset/good-wolves-remain.md create mode 100644 packages/astro/e2e/fixtures/lit-component/src/components/ClientOnlyComponent.js diff --git a/.changeset/good-wolves-remain.md b/.changeset/good-wolves-remain.md new file mode 100644 index 0000000000..05274b2136 --- /dev/null +++ b/.changeset/good-wolves-remain.md @@ -0,0 +1,6 @@ +--- +'@astrojs/lit': minor +'astro': patch +--- + +Implement client:only functionality in Lit and add lit to the client:only warning diff --git a/packages/astro/e2e/fixtures/lit-component/src/components/ClientOnlyComponent.js b/packages/astro/e2e/fixtures/lit-component/src/components/ClientOnlyComponent.js new file mode 100644 index 0000000000..0fd16b50af --- /dev/null +++ b/packages/astro/e2e/fixtures/lit-component/src/components/ClientOnlyComponent.js @@ -0,0 +1,9 @@ +import { LitElement, html } from 'lit'; + +export default class ClientOnlyComponent extends LitElement { + render() { + return html` Shadow dom default content should not be visible`; + } +} + +customElements.define('client-only-component', ClientOnlyComponent); diff --git a/packages/astro/e2e/fixtures/lit-component/src/pages/index.astro b/packages/astro/e2e/fixtures/lit-component/src/pages/index.astro index f15e832dcb..43eb17a4ec 100644 --- a/packages/astro/e2e/fixtures/lit-component/src/pages/index.astro +++ b/packages/astro/e2e/fixtures/lit-component/src/pages/index.astro @@ -1,6 +1,7 @@ --- import MyCounter from '../components/Counter.js'; import NonDeferredCounter from '../components/NonDeferredCounter.js'; +import ClientOnlyComponent from '../components/ClientOnlyComponent.js'; const someProps = { count: 10, @@ -26,5 +27,12 @@ const someProps = { Hello, client:visible! + + + Framework + client:only + component + Should not be visible +