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:
parent
48851c9d25
commit
59f6792b00
7 changed files with 27 additions and 36 deletions
|
@ -6,8 +6,8 @@ class Counter extends LitElement {
|
|||
static get properties() {
|
||||
return {
|
||||
count: {
|
||||
type: Number
|
||||
}
|
||||
type: Number,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -6,15 +6,13 @@ 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> `;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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];
|
||||
}
|
||||
});
|
||||
|
|
|
@ -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))
|
||||
if (
|
||||
!new DOMParser()
|
||||
.parseFromString(`<p><template shadowroot="open"></template></p>`, 'text/html', {
|
||||
includeShadowRoots: true,
|
||||
})
|
||||
.querySelector('p')?.shadowRoot
|
||||
)
|
||||
polyfill();
|
|
@ -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'],
|
||||
};
|
||||
|
|
|
@ -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,
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue