summaryrefslogtreecommitdiff
path: root/packages/integrations/lit/test/server.test.js
diff options
context:
space:
mode:
authorGravatar Reece McDonald <39349270+hrmcdonald@users.noreply.github.com> 2023-02-24 12:10:56 -0600
committerGravatar GitHub <noreply@github.com> 2023-02-24 12:10:56 -0600
commit26bf12ef3c7ab874a23ac753f841f7bb329c9361 (patch)
tree3e4a7ce83a135416efa61da7925cdd01b90a3f89 /packages/integrations/lit/test/server.test.js
parent5aa6580f775405a4443835bf7eb81f0c65e5aed6 (diff)
downloadastro-26bf12ef3c7ab874a23ac753f841f7bb329c9361.tar.gz
astro-26bf12ef3c7ab874a23ac753f841f7bb329c9361.tar.zst
astro-26bf12ef3c7ab874a23ac753f841f7bb329c9361.zip
[Lit] render DSD attributes based on `shadowRootOptions` (#6351)
* [Lit] render DSD attributes based on `shadowRootOptions` ## Changes - Update `@astrojs/lit`’s `server.js` to properly render elements with `delegatesFocus: false` set in their `shadowRootOptions`. - Logic is based on `@lit-labs/ssr` [latest implementation as found here](https://github.com/lit/lit/blob/b0c3f82ef0f97326a205e77e7e1043b75a5cc53f/packages/labs/ssr/src/lib/render-value.ts#L738) ## Testing A test was added to ensure an element with `delegatesFocus` set to true has this attribute properly included in the rendered static markup. * chore: add changeset
Diffstat (limited to 'packages/integrations/lit/test/server.test.js')
-rw-r--r--packages/integrations/lit/test/server.test.js11
1 files changed, 11 insertions, 0 deletions
diff --git a/packages/integrations/lit/test/server.test.js b/packages/integrations/lit/test/server.test.js
index 439c0877d..af1f99c71 100644
--- a/packages/integrations/lit/test/server.test.js
+++ b/packages/integrations/lit/test/server.test.js
@@ -83,4 +83,15 @@ describe('renderToStaticMarkup', () => {
expect($(tagName).attr('attr1')).to.equal(attr1);
expect($(`${tagName} template`).text()).to.contain(`Hello ${prop1}`);
});
+
+ it('should render DSD attributes based on shadowRootOptions', async () => {
+ const tagName = 'lit-component';
+ customElements.define(tagName, class extends LitElement {
+ static shadowRootOptions = {...LitElement.shadowRootOptions, delegatesFocus: true};
+ });
+ const render = await renderToStaticMarkup(tagName);
+ expect(render).to.deep.equal({
+ html: `<${tagName}><template shadowroot=\"open\" shadowrootmode=\"open\" shadowrootdelegatesfocus><!--lit-part--><!--/lit-part--></template></${tagName}>`,
+ });
+ });
});