From 7747f0099a0dd671e05eba302f16723aab43ef57 Mon Sep 17 00:00:00 2001 From: matthewp Date: Wed, 1 Feb 2023 13:20:23 +0000 Subject: [PATCH] [ci] format --- packages/astro/test/lit-element.test.js | 4 +-- packages/integrations/lit/src/client.ts | 40 +++++++++++-------------- 2 files changed, 19 insertions(+), 25 deletions(-) diff --git a/packages/astro/test/lit-element.test.js b/packages/astro/test/lit-element.test.js index 0b42c5699..9512909d8 100644 --- a/packages/astro/test/lit-element.test.js +++ b/packages/astro/test/lit-element.test.js @@ -47,9 +47,7 @@ describe('LitElement test', function () { // test 5: object reactive property set // by default objects will be stringified to [object Object] - expect(stripExpressionMarkers($('#default').html())).to.include( - `
data: 1
` - ); + expect(stripExpressionMarkers($('#default').html())).to.include(`
data: 1
`); // test 6: reactive properties are not rendered as attributes expect($('#default').attr('obj')).to.equal(undefined); diff --git a/packages/integrations/lit/src/client.ts b/packages/integrations/lit/src/client.ts index 00f126e34..fb92ac3df 100644 --- a/packages/integrations/lit/src/client.ts +++ b/packages/integrations/lit/src/client.ts @@ -1,25 +1,21 @@ -export default (element: HTMLElement) => - async ( - Component: any, - props: Record, - ) => { - // Get the LitElement element instance (may or may not be upgraded). - const component = element.children[0] as HTMLElement; +export default (element: HTMLElement) => async (Component: any, props: Record) => { + // Get the LitElement element instance (may or may not be upgraded). + const component = element.children[0] as HTMLElement; - // If there is no deferral of hydration, then all reactive properties are - // already serialzied as reflected attributes, or no reactive props were set - if (!component || !component.hasAttribute('defer-hydration')) { - return; + // If there is no deferral of hydration, then all reactive properties are + // already serialzied as reflected attributes, or no reactive props were set + if (!component || !component.hasAttribute('defer-hydration')) { + return; + } + + // Set properties on the LitElement instance for resuming hydration. + for (let [name, value] of Object.entries(props)) { + // Check if reactive property or class property. + if (name in Component.prototype) { + (component as any)[name] = value; } + } - // Set properties on the LitElement instance for resuming hydration. - for (let [name, value] of Object.entries(props)) { - // Check if reactive property or class property. - if (name in Component.prototype) { - (component as any)[name] = value; - } - } - - // Tell LitElement to resume hydration. - component.removeAttribute('defer-hydration'); - }; + // Tell LitElement to resume hydration. + component.removeAttribute('defer-hydration'); +};