Skip to content

Commit 84b50a6

Browse files
committed
pnpm run format
1 parent f8bf282 commit 84b50a6

File tree

6 files changed

+59
-45
lines changed

6 files changed

+59
-45
lines changed

packages/svelte/scripts/generate-types.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,11 @@ await createBundle({
2626
// so that types/properties with `@internal` (and its dependencies) are removed from the output
2727
stripInternal: true,
2828
paths: Object.fromEntries(
29-
Object.entries(pkg.imports).map(/** @param {[string,any]} import */([key, value]) => {
30-
return [key, [value.types ?? value.default ?? value]];
31-
})
29+
Object.entries(pkg.imports).map(
30+
/** @param {[string,any]} import */ ([key, value]) => {
31+
return [key, [value.types ?? value.default ?? value]];
32+
}
33+
)
3234
)
3335
},
3436
modules: {

packages/svelte/src/compiler/legacy.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ export function convert(source, ast) {
5555

5656
// Insert svelte:options back into the root nodes
5757
if (/** @type {any} */ (options)?.__raw__) {
58-
let idx = node.fragment.nodes.findIndex((node) => /** @type {any} */ (options).end <= node.start);
58+
let idx = node.fragment.nodes.findIndex(
59+
(node) => /** @type {any} */ (options).end <= node.start
60+
);
5961
if (idx === -1) {
6062
idx = node.fragment.nodes.length;
6163
}

packages/svelte/src/internal/client/reactivity/equality.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/** @import { Equals } from '#client' */
22

33
/** @type {Equals} */
4-
export const equals = function(value) {
4+
export const equals = function (value) {
55
return value === this.v;
6-
}
6+
};
77

88
/**
99
* @param {unknown} a
@@ -26,6 +26,6 @@ export function not_equal(a, b) {
2626
}
2727

2828
/** @type {Equals} */
29-
export const safe_equals = function(value) {
29+
export const safe_equals = function (value) {
3030
return !safe_not_equal(value, this.v);
31-
}
31+
};

packages/svelte/src/internal/client/reactivity/props.js

Lines changed: 36 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -361,21 +361,23 @@ export function prop(props, key, flags, fallback) {
361361
// means we can just call `$$props.foo = value` directly
362362
if (setter) {
363363
var legacy_parent = props.$$legacy;
364-
return /** @type {() => V} */ (function (/** @type {V} */ value, /** @type {boolean} */ mutation) {
365-
if (arguments.length > 0) {
366-
// We don't want to notify if the value was mutated and the parent is in runes mode.
367-
// In that case the state proxy (if it exists) should take care of the notification.
368-
// If the parent is not in runes mode, we need to notify on mutation, too, that the prop
369-
// has changed because the parent will not be able to detect the change otherwise.
370-
if (!runes || !mutation || legacy_parent || is_store_sub) {
371-
/** @type {Function} */ (setter)(mutation ? getter() : value);
364+
return /** @type {() => V} */ (
365+
function (/** @type {V} */ value, /** @type {boolean} */ mutation) {
366+
if (arguments.length > 0) {
367+
// We don't want to notify if the value was mutated and the parent is in runes mode.
368+
// In that case the state proxy (if it exists) should take care of the notification.
369+
// If the parent is not in runes mode, we need to notify on mutation, too, that the prop
370+
// has changed because the parent will not be able to detect the change otherwise.
371+
if (!runes || !mutation || legacy_parent || is_store_sub) {
372+
/** @type {Function} */ (setter)(mutation ? getter() : value);
373+
}
374+
375+
return value;
372376
}
373377

374-
return value;
378+
return getter();
375379
}
376-
377-
return getter();
378-
});
380+
);
379381
}
380382

381383
// Either prop is written to, but there's no binding, which means we
@@ -397,30 +399,32 @@ export function prop(props, key, flags, fallback) {
397399
if (bindable) get(d);
398400

399401
var parent_effect = /** @type {Effect} */ (active_effect);
400-
401-
return /** @type {() => V} */(function (/** @type {any} */ value, /** @type {boolean} */ mutation) {
402-
if (arguments.length > 0) {
403-
const new_value = mutation ? get(d) : runes && bindable ? proxy(value) : value;
404402

405-
set(d, new_value);
406-
overridden = true;
403+
return /** @type {() => V} */ (
404+
function (/** @type {any} */ value, /** @type {boolean} */ mutation) {
405+
if (arguments.length > 0) {
406+
const new_value = mutation ? get(d) : runes && bindable ? proxy(value) : value;
407+
408+
set(d, new_value);
409+
overridden = true;
410+
411+
if (fallback_value !== undefined) {
412+
fallback_value = new_value;
413+
}
407414

408-
if (fallback_value !== undefined) {
409-
fallback_value = new_value;
415+
return value;
410416
}
411417

412-
return value;
413-
}
418+
// special case — avoid recalculating the derived if we're in a
419+
// teardown function and the prop was overridden locally, or the
420+
// component was already destroyed (this latter part is necessary
421+
// because `bind:this` can read props after the component has
422+
// been destroyed. TODO simplify `bind:this`
423+
if ((is_destroying_effect && overridden) || (parent_effect.f & DESTROYED) !== 0) {
424+
return d.v;
425+
}
414426

415-
// special case — avoid recalculating the derived if we're in a
416-
// teardown function and the prop was overridden locally, or the
417-
// component was already destroyed (this latter part is necessary
418-
// because `bind:this` can read props after the component has
419-
// been destroyed. TODO simplify `bind:this`
420-
if ((is_destroying_effect && overridden) || (parent_effect.f & DESTROYED) !== 0) {
421-
return d.v;
427+
return get(d);
422428
}
423-
424-
return get(d);
425-
});
429+
);
426430
}

packages/svelte/src/internal/server/payload.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@ export class HeadPayload {
66
uid = () => '';
77
title = '';
88

9-
constructor(/** @type {Set<{ hash: string; code: string }>} */ css = new Set(), /** @type {string[]} */ out = [], title = '', uid = () => '') {
10-
9+
constructor(
10+
/** @type {Set<{ hash: string; code: string }>} */ css = new Set(),
11+
/** @type {string[]} */ out = [],
12+
title = '',
13+
uid = () => ''
14+
) {
1115
this.css = css;
1216
this.out = out;
1317
this.title = title;

packages/svelte/tests/runtime-browser/assert.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,11 @@ function normalize_html(window, html) {
8888
/** @param {any} node */
8989
function normalize_children(node) {
9090
// sort attributes
91-
const attributes = Array.from(node.attributes).sort((/** @type {any} */ a,/** @type {any} */ b) => {
92-
return a.name < b.name ? -1 : 1;
93-
});
91+
const attributes = Array.from(node.attributes).sort(
92+
(/** @type {any} */ a, /** @type {any} */ b) => {
93+
return a.name < b.name ? -1 : 1;
94+
}
95+
);
9496

9597
attributes.forEach((/** @type{any} */ attr) => {
9698
node.removeAttribute(attr.name);

0 commit comments

Comments
 (0)