[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() {
|
static get properties() {
|
||||||
return {
|
return {
|
||||||
count: {
|
count: {
|
||||||
type: Number
|
type: Number,
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,15 +6,13 @@ class CalcAdd extends LitElement {
|
||||||
static get properties() {
|
static get properties() {
|
||||||
return {
|
return {
|
||||||
num: {
|
num: {
|
||||||
type: Number
|
type: Number,
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return html`
|
return html` <div>Number: ${this.num}</div> `;
|
||||||
<div>Number: ${this.num}</div>
|
|
||||||
`;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ LitElement.skip('Renders a custom element by the constructor', async ({ runtime
|
||||||
LitElement.after(() => {
|
LitElement.after(() => {
|
||||||
const globals = Object.keys(globalThis.window);
|
const globals = Object.keys(globalThis.window);
|
||||||
globals.splice(globals.indexOf('global'), 1);
|
globals.splice(globals.indexOf('global'), 1);
|
||||||
for(let name of globals) {
|
for (let name of globals) {
|
||||||
delete globalThis[name];
|
delete globalThis[name];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,7 +3,11 @@ async function polyfill() {
|
||||||
hydrateShadowRoots(document.body);
|
hydrateShadowRoots(document.body);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!(new DOMParser().parseFromString(`<p><template shadowroot="open"></template></p>`, 'text/html', {
|
if (
|
||||||
includeShadowRoots: true
|
!new DOMParser()
|
||||||
}).querySelector('p')?.shadowRoot))
|
.parseFromString(`<p><template shadowroot="open"></template></p>`, 'text/html', {
|
||||||
|
includeShadowRoots: true,
|
||||||
|
})
|
||||||
|
.querySelector('p')?.shadowRoot
|
||||||
|
)
|
||||||
polyfill();
|
polyfill();
|
|
@ -1,19 +1,8 @@
|
||||||
export default {
|
export default {
|
||||||
name: '@astrojs/renderer-lit',
|
name: '@astrojs/renderer-lit',
|
||||||
server: './server.js',
|
server: './server.js',
|
||||||
external: [
|
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'],
|
||||||
'@lit-labs/ssr/lib/install-global-dom-shim.js',
|
polyfills: ['./client-shim.js'],
|
||||||
'@lit-labs/ssr/lib/render-lit-html.js',
|
hydrationPolyfills: ['lit/experimental-hydrate-support.js'],
|
||||||
'@lit-labs/ssr/lib/lit-element-renderer.js'
|
knownEntrypoints: ['@astrojs/renderer-lit/client-shim.js', '@webcomponents/template-shadowroot/template-shadowroot.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) {
|
function getCustomElementConstructor(name) {
|
||||||
if(typeof customElements !== 'undefined' && isCustomElementTag(name)) {
|
if (typeof customElements !== 'undefined' && isCustomElementTag(name)) {
|
||||||
return customElements.get(name) || null;
|
return customElements.get(name) || null;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -24,11 +24,11 @@ async function check(Component, _props, _children) {
|
||||||
return !!(await isLitElement(Component));
|
return !!(await isLitElement(Component));
|
||||||
}
|
}
|
||||||
|
|
||||||
function * render(tagName, attrs, children) {
|
function* render(tagName, attrs, children) {
|
||||||
const instance = new LitElementRenderer(tagName);
|
const instance = new LitElementRenderer(tagName);
|
||||||
|
|
||||||
// LitElementRenderer creates a new element instance, so copy over.
|
// 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);
|
instance.setAttribute(name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,16 +49,16 @@ async function renderToStaticMarkup(Component, props, children) {
|
||||||
let tagName = Component;
|
let tagName = Component;
|
||||||
|
|
||||||
let out = '';
|
let out = '';
|
||||||
for(let chunk of render(tagName, props, children)) {
|
for (let chunk of render(tagName, props, children)) {
|
||||||
out += chunk;
|
out += chunk;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
html: out
|
html: out,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
check,
|
check,
|
||||||
renderToStaticMarkup
|
renderToStaticMarkup,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue