Skip to content

Commit 73eff42

Browse files
committed
merge main
2 parents 843573a + 5a37d12 commit 73eff42

File tree

49 files changed

+563
-270
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+563
-270
lines changed

.changeset/eight-jeans-compare.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"svelte": patch
3+
---
4+
5+
fix: improve reactive Map and Set implementations

.changeset/gentle-ties-fetch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"svelte": patch
3+
---
4+
5+
fix: improve controlled each block cleanup performance

.changeset/ninety-rockets-battle.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"svelte": patch
3+
---
4+
5+
fix: allow for more svelte-ignore to work

.changeset/pre.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@
110110
"eight-carrots-hunt",
111111
"eight-cougars-watch",
112112
"eight-hornets-punch",
113+
"eight-jeans-compare",
113114
"eight-pianos-raise",
114115
"eight-steaks-shout",
115116
"eighty-bikes-camp",
@@ -170,6 +171,7 @@
170171
"gentle-dolls-juggle",
171172
"gentle-sheep-hug",
172173
"gentle-spies-happen",
174+
"gentle-ties-fetch",
173175
"gentle-toys-chew",
174176
"gentle-trees-exercise",
175177
"gentle-wasps-pull",
@@ -310,6 +312,7 @@
310312
"nine-cooks-join",
311313
"ninety-dingos-walk",
312314
"ninety-dots-train",
315+
"ninety-rockets-battle",
313316
"odd-buckets-lie",
314317
"odd-needles-joke",
315318
"odd-schools-wait",
@@ -412,6 +415,7 @@
412415
"shiny-baboons-play",
413416
"shiny-mayflies-clean",
414417
"shiny-melons-love",
418+
"shiny-months-tease",
415419
"shiny-rats-heal",
416420
"shiny-shrimps-march",
417421
"short-buses-camp",
@@ -425,11 +429,13 @@
425429
"silly-lies-film",
426430
"silly-ways-wash",
427431
"silver-points-approve",
432+
"silver-sheep-knock",
428433
"six-bears-trade",
429434
"six-boats-shave",
430435
"sixty-items-crash",
431436
"sixty-numbers-hope",
432437
"sixty-pandas-rush",
438+
"sixty-plants-cover",
433439
"sleepy-cats-eat",
434440
"slimy-clouds-talk",
435441
"slimy-hairs-impress",

.changeset/shiny-months-tease.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"svelte": patch
3+
---
4+
5+
fix: reevaluate namespace in slots

.changeset/silver-sheep-knock.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"svelte": patch
3+
---
4+
5+
chore: improve $state.frozen performance in prod

.changeset/sixty-plants-cover.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"svelte": patch
3+
---
4+
5+
breaking: removed deferred event updates

packages/svelte/CHANGELOG.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,29 @@
11
# svelte
22

3+
## 5.0.0-next.148
4+
5+
### Patch Changes
6+
7+
- chore: improve $state.frozen performance in prod ([#11852](https://github.com/sveltejs/svelte/pull/11852))
8+
9+
- breaking: removed deferred event updates ([#11855](https://github.com/sveltejs/svelte/pull/11855))
10+
11+
## 5.0.0-next.147
12+
13+
### Patch Changes
14+
15+
- fix: improve reactive Map and Set implementations ([#11827](https://github.com/sveltejs/svelte/pull/11827))
16+
17+
- fix: improve controlled each block cleanup performance ([#11839](https://github.com/sveltejs/svelte/pull/11839))
18+
19+
## 5.0.0-next.146
20+
21+
### Patch Changes
22+
23+
- fix: allow for more svelte-ignore to work ([#11833](https://github.com/sveltejs/svelte/pull/11833))
24+
25+
- fix: reevaluate namespace in slots ([#11849](https://github.com/sveltejs/svelte/pull/11849))
26+
327
## 5.0.0-next.145
428

529
### Patch Changes

packages/svelte/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "svelte",
33
"description": "Cybernetically enhanced web apps",
44
"license": "MIT",
5-
"version": "5.0.0-next.145",
5+
"version": "5.0.0-next.148",
66
"type": "module",
77
"types": "./types/index.d.ts",
88
"engines": {

packages/svelte/scripts/process-messages/templates/compile-warnings.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { filename, locator, warnings, ignore_stack } from './state.js';
1+
import { filename, locator, warnings, ignore_stack, ignore_map } from './state.js';
22

33
/** @typedef {{ start?: number, end?: number }} NodeLike */
44

@@ -8,7 +8,11 @@ import { filename, locator, warnings, ignore_stack } from './state.js';
88
* @param {string} message
99
*/
1010
function w(node, code, message) {
11-
if (ignore_stack.at(-1)?.has(code)) return;
11+
let stack = ignore_stack;
12+
if (node) {
13+
stack = ignore_map.get(node) ?? ignore_stack;
14+
}
15+
if (stack && stack.at(-1)?.has(code)) return;
1216

1317
warnings.push({
1418
code,

packages/svelte/src/compiler/phases/2-analyze/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import { prune } from './css/css-prune.js';
3030
import { hash } from './utils.js';
3131
import { warn_unused } from './css/css-warn.js';
3232
import { extract_svelte_ignore } from '../../utils/extract_svelte_ignore.js';
33-
import { pop_ignore, push_ignore } from '../../state.js';
33+
import { ignore_map, ignore_stack, pop_ignore, push_ignore } from '../../state.js';
3434

3535
/**
3636
* @param {import('#compiler').Script | null} script
@@ -1107,6 +1107,7 @@ function is_safe_identifier(expression, scope) {
11071107
/** @type {import('./types').Visitors} */
11081108
const common_visitors = {
11091109
_(node, { state, next, path }) {
1110+
ignore_map.set(node, structuredClone(ignore_stack));
11101111
const parent = path.at(-1);
11111112
if (parent?.type === 'Fragment' && node.type !== 'Comment' && node.type !== 'Text') {
11121113
const idx = parent.nodes.indexOf(/** @type {any} */ (node));
@@ -1129,6 +1130,7 @@ const common_visitors = {
11291130

11301131
if (ignores.length > 0) {
11311132
push_ignore(ignores);
1133+
ignore_map.set(node, structuredClone(ignore_stack));
11321134
next();
11331135
pop_ignore();
11341136
}
@@ -1148,6 +1150,7 @@ const common_visitors = {
11481150
}
11491151
if (ignores.length > 0) {
11501152
push_ignore(ignores);
1153+
ignore_map.set(node, structuredClone(ignore_stack));
11511154
next();
11521155
pop_ignore();
11531156
}

packages/svelte/src/compiler/phases/3-transform/utils.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,8 @@ export function infer_namespace(namespace, parent, nodes) {
176176
parent.type === 'Component' ||
177177
parent.type === 'SvelteComponent' ||
178178
parent.type === 'SvelteFragment' ||
179-
parent.type === 'SnippetBlock'
179+
parent.type === 'SnippetBlock' ||
180+
parent.type === 'SlotElement'
180181
) {
181182
const new_namespace = check_nodes_for_namespace(nodes, 'keep');
182183
if (new_namespace !== 'keep' && new_namespace !== 'maybe_html') {

packages/svelte/src/compiler/state.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,20 @@ export let filename;
1414

1515
export let locator = getLocator('', { offsetLine: 1 });
1616

17-
/** @type {Set<string>[]} */
17+
/**
18+
* The current stack of ignored warnings
19+
* @type {Set<string>[]}
20+
*/
1821
export let ignore_stack = [];
1922

23+
/**
24+
* For each node the list of warnings that should be ignored for that node.
25+
* Exists in addition to `ignore_stack` because not all warnings are emitted
26+
* while the stack is being built.
27+
* @type {Map<import("./types").SvelteNode | NodeLike, Set<string>[]>}
28+
*/
29+
export let ignore_map = new Map();
30+
2031
/**
2132
* @param {string[]} ignores
2233
*/
@@ -49,4 +60,5 @@ export function reset(source, options) {
4960
locator = getLocator(source, { offsetLine: 1 });
5061
warnings = [];
5162
ignore_stack = [];
63+
ignore_map.clear();
5264
}

packages/svelte/src/compiler/warnings.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
/* This file is generated by scripts/process-messages/index.js. Do not edit! */
22

3-
import { filename, locator, warnings, ignore_stack } from './state.js';
3+
import {
4+
filename,
5+
locator,
6+
warnings,
7+
ignore_stack,
8+
ignore_map
9+
} from './state.js';
410

511
/** @typedef {{ start?: number, end?: number }} NodeLike */
612
/**
@@ -9,7 +15,13 @@ import { filename, locator, warnings, ignore_stack } from './state.js';
915
* @param {string} message
1016
*/
1117
function w(node, code, message) {
12-
if (ignore_stack.at(-1)?.has(code)) return;
18+
let stack = ignore_stack;
19+
20+
if (node) {
21+
stack = ignore_map.get(node) ?? ignore_stack;
22+
}
23+
24+
if (stack && stack.at(-1)?.has(code)) return;
1325

1426
warnings.push({
1527
code,

packages/svelte/src/internal/client/constants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ export const EFFECT_TRANSPARENT = 1 << 15;
1818
export const LEGACY_DERIVED_PROP = 1 << 16;
1919

2020
export const STATE_SYMBOL = Symbol('$state');
21+
export const STATE_FROZEN_SYMBOL = Symbol('$state.frozen');
2122
export const LOADING_ATTR_SYMBOL = Symbol('');

packages/svelte/src/internal/client/dev/inspect.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,6 @@ export function inspect(get_value, inspector = console.log) {
6262
*/
6363
function deep_snapshot(value, visited = new Map()) {
6464
if (typeof value === 'object' && value !== null && !visited.has(value)) {
65-
if (DEV) {
66-
// When dealing with ReactiveMap or ReactiveSet, return normal versions
67-
// so that console.log provides better output versions
68-
if (value instanceof Map && value.constructor !== Map) {
69-
return new Map(value);
70-
}
71-
if (value instanceof Set && value.constructor !== Set) {
72-
return new Set(value);
73-
}
74-
}
7565
const unstated = snapshot(value);
7666

7767
if (unstated !== value) {

packages/svelte/src/internal/client/dom/blocks/each.js

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ export function index(_, i) {
5757
* subsequent destruction. Used in each blocks
5858
* @param {import('#client').EachItem[]} items
5959
* @param {null | Node} controlled_anchor
60-
* @param {() => void} [callback]
60+
* @param {Map<any, import("#client").EachItem>} items_map
6161
*/
62-
function pause_effects(items, controlled_anchor, callback) {
62+
function pause_effects(items, controlled_anchor, items_map) {
6363
/** @type {import('#client').TransitionManager[]} */
6464
var transitions = [];
6565
var length = items.length;
@@ -68,20 +68,29 @@ function pause_effects(items, controlled_anchor, callback) {
6868
pause_children(items[i].e, transitions, true);
6969
}
7070

71+
var is_controlled = length > 0 && transitions.length === 0 && controlled_anchor !== null;
7172
// If we have a controlled anchor, it means that the each block is inside a single
7273
// DOM element, so we can apply a fast-path for clearing the contents of the element.
73-
if (length > 0 && transitions.length === 0 && controlled_anchor !== null) {
74-
var parent_node = /** @type {Element} */ (controlled_anchor.parentNode);
74+
if (is_controlled) {
75+
var parent_node = /** @type {Element} */ (
76+
/** @type {Element} */ (controlled_anchor).parentNode
77+
);
7578
clear_text_content(parent_node);
76-
parent_node.append(controlled_anchor);
79+
parent_node.append(/** @type {Element} */ (controlled_anchor));
80+
items_map.clear();
81+
link(items[0].prev, items[length - 1].next);
7782
}
7883

7984
run_out_transitions(transitions, () => {
8085
for (var i = 0; i < length; i++) {
81-
destroy_effect(items[i].e);
86+
var item = items[i];
87+
if (!is_controlled) {
88+
items_map.delete(item.k);
89+
item.o.remove();
90+
link(item.prev, item.next);
91+
}
92+
destroy_effect(item.e, !is_controlled);
8293
}
83-
84-
if (callback !== undefined) callback();
8594
});
8695
}
8796

@@ -391,31 +400,27 @@ function reconcile(array, state, anchor, render_fn, flags, get_key) {
391400

392401
const to_destroy = Array.from(seen);
393402

394-
while (current) {
403+
while (current !== null) {
395404
to_destroy.push(current);
396405
current = current.next;
397406
}
407+
var destroy_length = to_destroy.length;
398408

399-
var controlled_anchor = (flags & EACH_IS_CONTROLLED) !== 0 && length === 0 ? anchor : null;
409+
if (destroy_length > 0) {
410+
var controlled_anchor = (flags & EACH_IS_CONTROLLED) !== 0 && length === 0 ? anchor : null;
400411

401-
if (is_animated) {
402-
for (i = 0; i < to_destroy.length; i += 1) {
403-
to_destroy[i].a?.measure();
404-
}
412+
if (is_animated) {
413+
for (i = 0; i < destroy_length; i += 1) {
414+
to_destroy[i].a?.measure();
415+
}
405416

406-
for (i = 0; i < to_destroy.length; i += 1) {
407-
to_destroy[i].a?.fix();
417+
for (i = 0; i < destroy_length; i += 1) {
418+
to_destroy[i].a?.fix();
419+
}
408420
}
409-
}
410421

411-
pause_effects(to_destroy, controlled_anchor, () => {
412-
for (var i = 0; i < to_destroy.length; i += 1) {
413-
var item = to_destroy[i];
414-
items.delete(item.k);
415-
item.o.remove();
416-
link(item.prev, item.next);
417-
}
418-
});
422+
pause_effects(to_destroy, controlled_anchor, items);
423+
}
419424

420425
if (is_animated) {
421426
effect(() => {

0 commit comments

Comments
 (0)