diff --git a/packages/astro/test/lit-element.test.js b/packages/astro/test/lit-element.test.js index 350248ab6..d314593a0 100644 --- a/packages/astro/test/lit-element.test.js +++ b/packages/astro/test/lit-element.test.js @@ -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'); diff --git a/packages/astro/test/slots-preact.test.js b/packages/astro/test/slots-preact.test.js index b655638b2..4cfb7218f 100644 --- a/packages/astro/test/slots-preact.test.js +++ b/packages/astro/test/slots-preact.test.js @@ -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'); - }) - }) + }); + }); }); diff --git a/packages/astro/test/slots-react.test.js b/packages/astro/test/slots-react.test.js index e84b02519..f3356dd58 100644 --- a/packages/astro/test/slots-react.test.js +++ b/packages/astro/test/slots-react.test.js @@ -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'); - }) - }) + }); + }); }); diff --git a/packages/astro/test/slots-solid.test.js b/packages/astro/test/slots-solid.test.js index faff85efc..ecef1839e 100644 --- a/packages/astro/test/slots-solid.test.js +++ b/packages/astro/test/slots-solid.test.js @@ -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'); - }) - }) + }); + }); }); diff --git a/packages/astro/test/slots-svelte.test.js b/packages/astro/test/slots-svelte.test.js index 9beab3281..917677587 100644 --- a/packages/astro/test/slots-svelte.test.js +++ b/packages/astro/test/slots-svelte.test.js @@ -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'); - }) - }) + }); + }); }); diff --git a/packages/astro/test/slots-vue.test.js b/packages/astro/test/slots-vue.test.js index dd2b612fe..64ec656e3 100644 --- a/packages/astro/test/slots-vue.test.js +++ b/packages/astro/test/slots-vue.test.js @@ -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'); - }) - }) + }); + }); }); diff --git a/packages/integrations/preact/client.js b/packages/integrations/preact/client.js index e2f4ca803..78d8720f0 100644 --- a/packages/integrations/preact/client.js +++ b/packages/integrations/preact/client.js @@ -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 + ); + }; diff --git a/packages/integrations/preact/server.js b/packages/integrations/preact/server.js index 31f980aa3..29ae8a3b0 100644 --- a/packages/integrations/preact/server.js +++ b/packages/integrations/preact/server.js @@ -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) ); diff --git a/packages/integrations/react/server-v17.js b/packages/integrations/react/server-v17.js index 5d747a832..8613ef01a 100644 --- a/packages/integrations/react/server-v17.js +++ b/packages/integrations/react/server-v17.js @@ -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) { diff --git a/packages/integrations/react/server.js b/packages/integrations/react/server.js index cda839a1c..5e4454151 100644 --- a/packages/integrations/react/server.js +++ b/packages/integrations/react/server.js @@ -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) { diff --git a/packages/integrations/solid/client.js b/packages/integrations/solid/client.js index ceb7546d2..fa8cabcc0 100644 --- a/packages/integrations/solid/client.js +++ b/packages/integrations/solid/client.js @@ -34,7 +34,7 @@ export default (element) => createComponent(Component, { ...props, ...slots, - children + children, }), element ); diff --git a/packages/integrations/solid/server.js b/packages/integrations/solid/server.js index 92b614012..2398ec317 100644 --- a/packages/integrations/solid/server.js +++ b/packages/integrations/solid/server.js @@ -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(`${value}`); } // 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(`${children}`) : children, - } + }; const html = renderToString(() => createComponent(Component, newProps)); - return { html } + return { html }; } export default { diff --git a/packages/integrations/svelte/client.js b/packages/integrations/svelte/client.js index 36a8e8de1..c8c252eaa 100644 --- a/packages/integrations/svelte/client.js +++ b/packages/integrations/svelte/client.js @@ -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', `${children}`) + target.insertAdjacentHTML( + 'beforeend', + `${children}` + ); }, // create c: noop, @@ -37,7 +40,7 @@ function createSlotDefinition(key, children) { // destroy d: noop, }), - noop, - noop, - ] + noop, + noop, + ]; } diff --git a/packages/integrations/svelte/server.js b/packages/integrations/svelte/server.js index 7a5610b4a..98ece3314 100644 --- a/packages/integrations/svelte/server.js +++ b/packages/integrations/svelte/server.js @@ -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] = () => `${value}`; + slots[key] = () => + `${value}`; } const { html } = Component.render(props, { $$slots: slots }); return { html }; diff --git a/packages/webapi/mod.d.ts b/packages/webapi/mod.d.ts index b385e82a5..a3c49dc5c 100644 --- a/packages/webapi/mod.d.ts +++ b/packages/webapi/mod.d.ts @@ -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;