[ci] format

This commit is contained in:
natemoo-re 2023-08-29 14:32:02 +00:00 committed by astrobot-houston
parent 1f58a7a1be
commit 51e67e0ab0
5 changed files with 19 additions and 13 deletions

View file

@ -52,10 +52,14 @@ declare const Astro: {
public hydrator: any;
static observedAttributes = ['props'];
disconnectedCallback() {
document.addEventListener('astro:after-swap', () => {
// If element wasn't persisted, fire unmount event
if (!this.isConnected) this.dispatchEvent(new CustomEvent('astro:unmount'))
}, { once: true })
document.addEventListener(
'astro:after-swap',
() => {
// If element wasn't persisted, fire unmount event
if (!this.isConnected) this.dispatchEvent(new CustomEvent('astro:unmount'));
},
{ once: true }
);
}
connectedCallback() {
if (!this.hasAttribute('await-children') || this.firstChild) {

View file

@ -1,6 +1,6 @@
import type { SignalLike } from './types';
import { h, render, hydrate } from 'preact';
import { h, hydrate, render } from 'preact';
import StaticHtml from './static-html.js';
import type { SignalLike } from './types';
const sharedSignalMap = new Map<string, SignalLike>();
@ -32,9 +32,9 @@ export default (element: HTMLElement) =>
bootstrap(
h(Component, props, children != null ? h(StaticHtml, { value: children }) : children),
element,
element
);
// Preact has no "unmount" option, but you can use `render(null, element)`
element.addEventListener('astro:unmount', () => render(null, element), { once: true })
element.addEventListener('astro:unmount', () => render(null, element), { once: true });
};

View file

@ -16,5 +16,7 @@ export default (element) =>
const isHydrate = client !== 'only';
const bootstrap = isHydrate ? hydrate : render;
bootstrap(componentEl, element);
element.addEventListener('astro:unmount', () => unmountComponentAtNode(element), { once: true });
element.addEventListener('astro:unmount', () => unmountComponentAtNode(element), {
once: true,
});
};

View file

@ -43,5 +43,5 @@ export default (element: HTMLElement) =>
}
);
element.addEventListener('astro:unmount', () => dispose(), { once: true })
element.addEventListener('astro:unmount', () => dispose(), { once: true });
};

View file

@ -24,8 +24,8 @@ export default (target) => {
hydrate: client !== 'only',
$$inline: true,
});
element.addEventListener('astro:unmount', () => component.$destroy(), { once: true })
element.addEventListener('astro:unmount', () => component.$destroy(), { once: true });
} catch (e) {
} finally {
if (import.meta.env.DEV) finishUsingConsoleFilter();