[ci] format

This commit is contained in:
natemoo-re 2022-06-23 15:12:46 +00:00 committed by github-actions[bot]
parent 7373d61cdc
commit 059d00bd5d
15 changed files with 65 additions and 60 deletions

View file

@ -73,7 +73,7 @@ describe('LitElement test', function () {
expect($('my-element').length).to.equal(1);
const [defaultSlot, namedSlot] = $('template').siblings().toArray();
// has default slot content in lightdom
expect($(defaultSlot).text()).to.equal('default');

View file

@ -26,13 +26,13 @@ describe('Slots: Preact', () => {
const html = await fixture.readFile('/index.html');
const $ = cheerio.load(html);
expect($('#named').text().trim()).to.equal('Fallback / Named');
})
});
it('Converts dash-case slot to camelCase', async () => {
const html = await fixture.readFile('/index.html');
const $ = cheerio.load(html);
expect($('#dash-case').text().trim()).to.equal('Fallback / Dash Case');
})
});
describe('For Markdown Pages', () => {
it('Renders default slot', async () => {
@ -45,12 +45,12 @@ describe('Slots: Preact', () => {
const html = await fixture.readFile('/markdown/index.html');
const $ = cheerio.load(html);
expect($('#named').text().trim()).to.equal('Fallback / Named');
})
});
it('Converts dash-case slot to camelCase', async () => {
const html = await fixture.readFile('/markdown/index.html');
const $ = cheerio.load(html);
expect($('#dash-case').text().trim()).to.equal('Fallback / Dash Case');
})
})
});
});
});

View file

@ -26,13 +26,13 @@ describe('Slots: React', () => {
const html = await fixture.readFile('/index.html');
const $ = cheerio.load(html);
expect($('#named').text().trim()).to.equal('Fallback / Named');
})
});
it('Converts dash-case slot to camelCase', async () => {
const html = await fixture.readFile('/index.html');
const $ = cheerio.load(html);
expect($('#dash-case').text().trim()).to.equal('Fallback / Dash Case');
})
});
describe('For Markdown Pages', () => {
it('Renders default slot', async () => {
@ -45,12 +45,12 @@ describe('Slots: React', () => {
const html = await fixture.readFile('/markdown/index.html');
const $ = cheerio.load(html);
expect($('#named').text().trim()).to.equal('Fallback / Named');
})
});
it('Converts dash-case slot to camelCase', async () => {
const html = await fixture.readFile('/markdown/index.html');
const $ = cheerio.load(html);
expect($('#dash-case').text().trim()).to.equal('Fallback / Dash Case');
})
})
});
});
});

View file

@ -26,13 +26,13 @@ describe('Slots: Solid', () => {
const html = await fixture.readFile('/index.html');
const $ = cheerio.load(html);
expect($('#named').text().trim()).to.equal('Fallback / Named');
})
});
it('Converts dash-case slot to camelCase', async () => {
const html = await fixture.readFile('/index.html');
const $ = cheerio.load(html);
expect($('#dash-case').text().trim()).to.equal('Fallback / Dash Case');
})
});
describe('For Markdown Pages', () => {
it('Renders default slot', async () => {
@ -45,12 +45,12 @@ describe('Slots: Solid', () => {
const html = await fixture.readFile('/markdown/index.html');
const $ = cheerio.load(html);
expect($('#named').text().trim()).to.equal('Fallback / Named');
})
});
it('Converts dash-case slot to camelCase', async () => {
const html = await fixture.readFile('/markdown/index.html');
const $ = cheerio.load(html);
expect($('#dash-case').text().trim()).to.equal('Fallback / Dash Case');
})
})
});
});
});

View file

@ -26,13 +26,13 @@ describe('Slots: Svelte', () => {
const html = await fixture.readFile('/index.html');
const $ = cheerio.load(html);
expect($('#named').text().trim()).to.equal('Fallback / Named');
})
});
it('Preserves dash-case slot', async () => {
const html = await fixture.readFile('/index.html');
const $ = cheerio.load(html);
expect($('#dash-case').text().trim()).to.equal('Fallback / Dash Case');
})
});
describe('For Markdown Pages', () => {
it('Renders default slot', async () => {
@ -45,12 +45,12 @@ describe('Slots: Svelte', () => {
const html = await fixture.readFile('/markdown/index.html');
const $ = cheerio.load(html);
expect($('#named').text().trim()).to.equal('Fallback / Named');
})
});
it('Converts dash-case slot to camelCase', async () => {
const html = await fixture.readFile('/markdown/index.html');
const $ = cheerio.load(html);
expect($('#dash-case').text().trim()).to.equal('Fallback / Dash Case');
})
})
});
});
});

View file

@ -26,13 +26,13 @@ describe('Slots: Vue', () => {
const html = await fixture.readFile('/index.html');
const $ = cheerio.load(html);
expect($('#named').text().trim()).to.equal('Fallback / Named');
})
});
it('Preserves dash-case slot', async () => {
const html = await fixture.readFile('/index.html');
const $ = cheerio.load(html);
expect($('#dash-case').text().trim()).to.equal('Fallback / Dash Case');
})
});
describe('For Markdown Pages', () => {
it('Renders default slot', async () => {
@ -45,12 +45,12 @@ describe('Slots: Vue', () => {
const html = await fixture.readFile('/markdown/index.html');
const $ = cheerio.load(html);
expect($('#named').text().trim()).to.equal('Fallback / Named');
})
});
it('Converts dash-case slot to camelCase', async () => {
const html = await fixture.readFile('/markdown/index.html');
const $ = cheerio.load(html);
expect($('#dash-case').text().trim()).to.equal('Fallback / Dash Case');
})
})
});
});
});

View file

@ -1,13 +1,14 @@
import { h, render } from 'preact';
import StaticHtml from './static-html.js';
export default (element) => (Component, props, { default: children, ...slotted }) => {
if (!element.hasAttribute('ssr')) return;
for (const [key, value] of Object.entries(slotted)) {
props[key] = h(StaticHtml, { value, name: key });
}
render(
h(Component, props, children != null ? h(StaticHtml, { value: children }) : children),
element
);
};
export default (element) =>
(Component, props, { default: children, ...slotted }) => {
if (!element.hasAttribute('ssr')) return;
for (const [key, value] of Object.entries(slotted)) {
props[key] = h(StaticHtml, { value, name: key });
}
render(
h(Component, props, children != null ? h(StaticHtml, { value: children }) : children),
element
);
};

View file

@ -2,7 +2,7 @@ import { h, Component as BaseComponent } from 'preact';
import render from 'preact-render-to-string';
import StaticHtml from './static-html.js';
const slotName = str => str.trim().replace(/[-_]([a-z])/g, (_, w) => w.toUpperCase());
const slotName = (str) => str.trim().replace(/[-_]([a-z])/g, (_, w) => w.toUpperCase());
function check(Component, props, children) {
if (typeof Component !== 'function') return false;
@ -33,7 +33,7 @@ function renderToStaticMarkup(Component, props, { default: children, ...slotted
slots[name] = h(StaticHtml, { value, name });
}
// Note: create newProps to avoid mutating `props` before they are serialized
const newProps = { ...props, ...slots }
const newProps = { ...props, ...slots };
const html = render(
h(Component, newProps, children != null ? h(StaticHtml, { value: children }) : children)
);

View file

@ -2,7 +2,7 @@ import React from 'react';
import ReactDOM from 'react-dom/server.js';
import StaticHtml from './static-html.js';
const slotName = str => str.trim().replace(/[-_]([a-z])/g, (_, w) => w.toUpperCase());
const slotName = (str) => str.trim().replace(/[-_]([a-z])/g, (_, w) => w.toUpperCase());
const reactTypeof = Symbol.for('react.element');
function errorIsComingFromPreactComponent(err) {
@ -59,11 +59,11 @@ function renderToStaticMarkup(Component, props, { default: children, ...slotted
slots[name] = React.createElement(StaticHtml, { value, name });
}
// Note: create newProps to avoid mutating `props` before they are serialized
const newProps = {
const newProps = {
...props,
...slots,
children: children != null ? React.createElement(StaticHtml, { value: children }) : undefined,
}
};
const vnode = React.createElement(Component, newProps);
let html;
if (metadata && metadata.hydrate) {

View file

@ -2,7 +2,7 @@ import React from 'react';
import ReactDOM from 'react-dom/server';
import StaticHtml from './static-html.js';
const slotName = str => str.trim().replace(/[-_]([a-z])/g, (_, w) => w.toUpperCase());
const slotName = (str) => str.trim().replace(/[-_]([a-z])/g, (_, w) => w.toUpperCase());
const reactTypeof = Symbol.for('react.element');
function errorIsComingFromPreactComponent(err) {
@ -65,11 +65,11 @@ async function renderToStaticMarkup(Component, props, { default: children, ...sl
slots[name] = React.createElement(StaticHtml, { value, name });
}
// Note: create newProps to avoid mutating `props` before they are serialized
const newProps = {
const newProps = {
...props,
...slots,
children: children != null ? React.createElement(StaticHtml, { value: children }) : undefined,
}
};
const vnode = React.createElement(Component, newProps);
let html;
if (metadata && metadata.hydrate) {

View file

@ -34,7 +34,7 @@ export default (element) =>
createComponent(Component, {
...props,
...slots,
children
children,
}),
element
);

View file

@ -1,6 +1,6 @@
import { renderToString, ssr, createComponent } from 'solid-js/web';
const slotName = str => str.trim().replace(/[-_]([a-z])/g, (_, w) => w.toUpperCase());
const slotName = (str) => str.trim().replace(/[-_]([a-z])/g, (_, w) => w.toUpperCase());
function check(Component, props, children) {
if (typeof Component !== 'function') return false;
@ -15,14 +15,14 @@ function renderToStaticMarkup(Component, props, { default: children, ...slotted
slots[name] = ssr(`<astro-slot name="${name}">${value}</astro-slot>`);
}
// Note: create newProps to avoid mutating `props` before they are serialized
const newProps = {
const newProps = {
...props,
...slots,
// In Solid SSR mode, `ssr` creates the expected structure for `children`.
children: children != null ? ssr(`<astro-slot>${children}</astro-slot>`) : children,
}
};
const html = renderToString(() => createComponent(Component, newProps));
return { html }
return { html };
}
export default {

View file

@ -11,10 +11,10 @@ export default (target) => {
try {
new Component({
target,
props: {
props: {
...props,
$$slots: slots,
$$scope: { ctx: [] }
$$scope: { ctx: [] },
},
hydrate: client !== 'only',
$$inline: true,
@ -24,11 +24,14 @@ export default (target) => {
};
function createSlotDefinition(key, children) {
return [
() => ({
return [
() => ({
// mount
m(target) {
target.insertAdjacentHTML('beforeend', `<astro-slot${key === 'default' ? '' : ` name="${key}"`}>${children}</astro-slot>`)
target.insertAdjacentHTML(
'beforeend',
`<astro-slot${key === 'default' ? '' : ` name="${key}"`}>${children}</astro-slot>`
);
},
// create
c: noop,
@ -37,7 +40,7 @@ function createSlotDefinition(key, children) {
// destroy
d: noop,
}),
noop,
noop,
]
noop,
noop,
];
}

View file

@ -5,7 +5,8 @@ function check(Component) {
async function renderToStaticMarkup(Component, props, slotted) {
const slots = {};
for (const [key, value] of Object.entries(slotted)) {
slots[key] = () => `<astro-slot${key === 'default' ? '' : ` name="${key}"`}>${value}</astro-slot>`;
slots[key] = () =>
`<astro-slot${key === 'default' ? '' : ` name="${key}"`}>${value}</astro-slot>`;
}
const { html } = Component.render(props, { $$slots: slots });
return { html };

View file

@ -1,5 +1,5 @@
export { pathToPosix } from './lib/utils';
export { AbortController, AbortSignal, alert, atob, Blob, btoa, ByteLengthQueuingStrategy, cancelAnimationFrame, cancelIdleCallback, CanvasRenderingContext2D, CharacterData, clearTimeout, Comment, CountQueuingStrategy, CSSStyleSheet, CustomElementRegistry, CustomEvent, Document, DocumentFragment, DOMException, Element, Event, EventTarget, fetch, File, FormData, Headers, HTMLBodyElement, HTMLCanvasElement, HTMLDivElement, HTMLDocument, HTMLElement, HTMLHeadElement, HTMLHtmlElement, HTMLImageElement, HTMLSpanElement, HTMLStyleElement, HTMLTemplateElement, HTMLUnknownElement, Image, ImageData, IntersectionObserver, MediaQueryList, MutationObserver, Node, NodeFilter, NodeIterator, OffscreenCanvas, ReadableByteStreamController, ReadableStream, ReadableStreamBYOBReader, ReadableStreamBYOBRequest, ReadableStreamDefaultController, ReadableStreamDefaultReader, Request, requestAnimationFrame, requestIdleCallback, ResizeObserver, Response, setTimeout, ShadowRoot, structuredClone, StyleSheet, Text, TransformStream, TreeWalker, URLPattern, Window, WritableStream, WritableStreamDefaultController, WritableStreamDefaultWriter, } from './mod.js';
export { AbortController, AbortSignal, alert, atob, Blob, btoa, ByteLengthQueuingStrategy, cancelAnimationFrame, cancelIdleCallback, CanvasRenderingContext2D, CharacterData, clearTimeout, Comment, CountQueuingStrategy, CSSStyleSheet, CustomElementRegistry, CustomEvent, Document, DocumentFragment, DOMException, Element, Event, EventTarget, fetch, File, FormData, Headers, HTMLBodyElement, HTMLCanvasElement, HTMLDivElement, HTMLDocument, HTMLElement, HTMLHeadElement, HTMLHtmlElement, HTMLImageElement, HTMLSpanElement, HTMLStyleElement, HTMLTemplateElement, HTMLUnknownElement, Image, ImageData, IntersectionObserver, MediaQueryList, MutationObserver, Node, NodeFilter, NodeIterator, OffscreenCanvas, ReadableByteStreamController, ReadableStream, ReadableStreamBYOBReader, ReadableStreamBYOBRequest, ReadableStreamDefaultController, ReadableStreamDefaultReader, Request, requestAnimationFrame, requestIdleCallback, ResizeObserver, Response, setTimeout, ShadowRoot, structuredClone, StyleSheet, Text, TransformStream, TreeWalker, URLPattern, Window, WritableStream, WritableStreamDefaultController, WritableStreamDefaultWriter } from './mod.js';
export declare const polyfill: {
(target: any, options?: PolyfillOptions): any;
internals(target: any, name: string): any;