0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-16 21:46:22 -05:00

[ci] yarn format

This commit is contained in:
matthewp 2021-07-13 12:28:50 +00:00 committed by GitHub Actions
parent 48851c9d25
commit 59f6792b00
7 changed files with 27 additions and 36 deletions

View file

@ -6,8 +6,8 @@ class Counter extends LitElement {
static get properties() {
return {
count: {
type: Number
}
type: Number,
},
};
}
@ -31,4 +31,4 @@ class Counter extends LitElement {
}
}
customElements.define(tagName, Counter);
customElements.define(tagName, Counter);

View file

@ -6,16 +6,14 @@ class CalcAdd extends LitElement {
static get properties() {
return {
num: {
type: Number
}
type: Number,
},
};
}
render() {
return html`
<div>Number: ${this.num}</div>
`;
return html` <div>Number: ${this.num}</div> `;
}
}
customElements.define(tagName, CalcAdd);
customElements.define(tagName, CalcAdd);

View file

@ -32,7 +32,7 @@ LitElement.skip('Renders a custom element by the constructor', async ({ runtime
LitElement.after(() => {
const globals = Object.keys(globalThis.window);
globals.splice(globals.indexOf('global'), 1);
for(let name of globals) {
for (let name of globals) {
delete globalThis[name];
}
});

View file

@ -3,7 +3,11 @@ async function polyfill() {
hydrateShadowRoots(document.body);
}
if(!(new DOMParser().parseFromString(`<p><template shadowroot="open"></template></p>`, 'text/html', {
includeShadowRoots: true
}).querySelector('p')?.shadowRoot))
polyfill();
if (
!new DOMParser()
.parseFromString(`<p><template shadowroot="open"></template></p>`, 'text/html', {
includeShadowRoots: true,
})
.querySelector('p')?.shadowRoot
)
polyfill();

View file

@ -1,19 +1,8 @@
export default {
name: '@astrojs/renderer-lit',
server: './server.js',
external: [
'@lit-labs/ssr/lib/install-global-dom-shim.js',
'@lit-labs/ssr/lib/render-lit-html.js',
'@lit-labs/ssr/lib/lit-element-renderer.js'
],
polyfills: [
'./client-shim.js'
],
hydrationPolyfills: [
'lit/experimental-hydrate-support.js'
],
knownEntrypoints: [
'@astrojs/renderer-lit/client-shim.js',
'@webcomponents/template-shadowroot/template-shadowroot.js'
]
external: ['@lit-labs/ssr/lib/install-global-dom-shim.js', '@lit-labs/ssr/lib/render-lit-html.js', '@lit-labs/ssr/lib/lit-element-renderer.js'],
polyfills: ['./client-shim.js'],
hydrationPolyfills: ['lit/experimental-hydrate-support.js'],
knownEntrypoints: ['@astrojs/renderer-lit/client-shim.js', '@webcomponents/template-shadowroot/template-shadowroot.js'],
};

View file

@ -1,2 +1,2 @@
import '@lit-labs/ssr/lib/install-global-dom-shim.js';
document.getElementsByTagName = () => [];
document.getElementsByTagName = () => [];

View file

@ -7,7 +7,7 @@ function isCustomElementTag(name) {
}
function getCustomElementConstructor(name) {
if(typeof customElements !== 'undefined' && isCustomElementTag(name)) {
if (typeof customElements !== 'undefined' && isCustomElementTag(name)) {
return customElements.get(name) || null;
}
return null;
@ -24,11 +24,11 @@ async function check(Component, _props, _children) {
return !!(await isLitElement(Component));
}
function * render(tagName, attrs, children) {
function* render(tagName, attrs, children) {
const instance = new LitElementRenderer(tagName);
// LitElementRenderer creates a new element instance, so copy over.
for(let [name, value] of Object.entries(attrs)) {
for (let [name, value] of Object.entries(attrs)) {
instance.setAttribute(name, value);
}
@ -49,16 +49,16 @@ async function renderToStaticMarkup(Component, props, children) {
let tagName = Component;
let out = '';
for(let chunk of render(tagName, props, children)) {
for (let chunk of render(tagName, props, children)) {
out += chunk;
}
return {
html: out
html: out,
};
}
export default {
check,
renderToStaticMarkup
renderToStaticMarkup,
};