Skip to content

Commit 6f32d21

Browse files
committed
merge main
2 parents 7923b5a + 9873443 commit 6f32d21

File tree

38 files changed

+240
-35
lines changed

38 files changed

+240
-35
lines changed

.changeset/short-fireants-talk.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

documentation/docs/02-runes/06-$bindable.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Now, a component that uses `<FancyInput>` can add the [`bind:`](bind) directive
3333

3434
<!-- prettier-ignore -->
3535
```svelte
36-
/// App.svelte
36+
/// file: App.svelte
3737
<script>
3838
import FancyInput from './FancyInput.svelte';
3939

documentation/docs/03-template-syntax/11-bind.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ Elements with the `contenteditable` attribute support the following bindings:
267267
<!-- for some reason puts the comment and html on same line -->
268268
<!-- prettier-ignore -->
269269
```svelte
270-
<div contenteditable="true" bind:innerHTML={html} />
270+
<div contenteditable="true" bind:innerHTML={html}></div>
271271
```
272272

273273
## Dimensions
@@ -307,7 +307,7 @@ To get a reference to a DOM node, use `bind:this`. The value will be `undefined`
307307
});
308308
</script>
309309
310-
<canvas bind:this={canvas} />
310+
<canvas bind:this={canvas}></canvas>
311311
```
312312

313313
Components also support `bind:this`, allowing you to interact with component instances programmatically.

packages/svelte/CHANGELOG.md

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

3+
## 5.20.2
4+
5+
### Patch Changes
6+
7+
- chore: remove unused `options.uid` in `render` ([#15302](https://github.com/sveltejs/svelte/pull/15302))
8+
9+
- fix: do not warn for `binding_property_non_reactive` if binding is a store in an each ([#15318](https://github.com/sveltejs/svelte/pull/15318))
10+
11+
- fix: prevent writable store value from becoming a proxy when reassigning using $-prefix ([#15283](https://github.com/sveltejs/svelte/pull/15283))
12+
13+
- fix: `muted` reactive without `bind` and select/autofocus attributes working with function calls ([#15326](https://github.com/sveltejs/svelte/pull/15326))
14+
15+
- fix: ensure input elements and elements with `dir` attribute are marked as non-static ([#15259](https://github.com/sveltejs/svelte/pull/15259))
16+
17+
- fix: fire delegated events on target even it was disabled in the meantime ([#15319](https://github.com/sveltejs/svelte/pull/15319))
18+
19+
## 5.20.1
20+
21+
### Patch Changes
22+
23+
- fix: ensure AST analysis on `svelte.js` modules succeeds ([#15297](https://github.com/sveltejs/svelte/pull/15297))
24+
25+
- fix: ignore typescript abstract methods ([#15267](https://github.com/sveltejs/svelte/pull/15267))
26+
27+
- fix: correctly ssr component in `svelte:head` with `$props.id()` or `css='injected'` ([#15291](https://github.com/sveltejs/svelte/pull/15291))
28+
329
## 5.20.0
430

531
### Minor 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.20.0",
5+
"version": "5.20.2",
66
"type": "module",
77
"types": "./types/index.d.ts",
88
"engines": {

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

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -262,10 +262,20 @@ export function analyze_module(ast, options) {
262262
{
263263
scope,
264264
scopes,
265-
// @ts-expect-error TODO
266-
analysis,
267-
// @ts-expect-error TODO
268-
options
265+
analysis: /** @type {ComponentAnalysis} */ (analysis),
266+
derived_state: [],
267+
// TODO the following are not needed for modules, but we have to pass them in order to avoid type error,
268+
// and reducing the type would result in a lot of tedious type casts elsewhere - find a good solution one day
269+
ast_type: /** @type {any} */ (null),
270+
component_slots: new Set(),
271+
expression: null,
272+
function_depth: 0,
273+
has_props_rune: false,
274+
instance_scope: /** @type {any} */ (null),
275+
options: /** @type {ValidatedCompileOptions} */ (options),
276+
parent_element: null,
277+
reactive_statement: null,
278+
reactive_statements: new Map()
269279
},
270280
visitors
271281
);

packages/svelte/src/compiler/phases/3-transform/client/types.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export interface ComponentClientTransformState extends ClientTransformState {
4545
readonly hoisted: Array<Statement | ModuleDeclaration>;
4646
readonly events: Set<string>;
4747
readonly is_instance: boolean;
48+
readonly store_to_invalidate?: string;
4849

4950
/** Stuff that happens before the render effect(s) */
5051
readonly init: Statement[];

packages/svelte/src/compiler/phases/3-transform/client/visitors/AssignmentExpression.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ function build_assignment(operator, left, right, context) {
118118
binding.kind !== 'prop' &&
119119
binding.kind !== 'bindable_prop' &&
120120
binding.kind !== 'raw_state' &&
121+
binding.kind !== 'store_sub' &&
121122
context.state.analysis.runes &&
122123
should_proxy(right, context.state.scope) &&
123124
is_non_coercive_operator(operator)

packages/svelte/src/compiler/phases/3-transform/client/visitors/EachBlock.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ export function EachBlock(node, context) {
143143

144144
const child_state = {
145145
...context.state,
146-
transform: { ...context.state.transform }
146+
transform: { ...context.state.transform },
147+
store_to_invalidate
147148
};
148149

149150
/** The state used when generating the key function, if necessary */

packages/svelte/src/compiler/phases/3-transform/client/visitors/RegularElement.js

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ import {
2929
build_render_statement,
3030
build_template_chunk,
3131
build_update_assignment,
32-
get_expression_id
32+
get_expression_id,
33+
memoize_expression
3334
} from './shared/utils.js';
3435
import { visit_event_attribute } from './shared/events.js';
3536

@@ -536,20 +537,30 @@ function build_element_attribute_update_assignment(
536537
const is_svg = context.state.metadata.namespace === 'svg' || element.name === 'svg';
537538
const is_mathml = context.state.metadata.namespace === 'mathml';
538539

540+
const is_autofocus = name === 'autofocus';
541+
539542
let { value, has_state } = build_attribute_value(attribute.value, context, (value, metadata) =>
540543
metadata.has_call || metadata.is_async
541-
? get_expression_id(metadata.is_async ? state.async_expressions : state.expressions, value)
544+
? // if it's autofocus we will not add this to a template effect so we don't want to get the expression id
545+
// but separately memoize the expression
546+
is_autofocus
547+
? memoize_expression(state, value)
548+
: get_expression_id(metadata.is_async ? state.async_expressions : state.expressions, value)
542549
: value
543550
);
544551

545-
if (name === 'autofocus') {
552+
if (is_autofocus) {
546553
state.init.push(b.stmt(b.call('$.autofocus', node_id, value)));
547554
return false;
548555
}
549556

550557
// Special case for Firefox who needs it set as a property in order to work
551558
if (name === 'muted') {
552-
state.init.push(b.stmt(b.assignment('=', b.member(node_id, b.id('muted')), value)));
559+
if (!has_state) {
560+
state.init.push(b.stmt(b.assignment('=', b.member(node_id, b.id('muted')), value)));
561+
return false;
562+
}
563+
state.update.push(b.stmt(b.assignment('=', b.member(node_id, b.id('muted')), value)));
553564
return false;
554565
}
555566

@@ -666,9 +677,17 @@ function build_custom_element_attribute_update_assignment(node_id, attribute, co
666677
*/
667678
function build_element_special_value_attribute(element, node_id, attribute, context) {
668679
const state = context.state;
680+
const is_select_with_value =
681+
// attribute.metadata.dynamic would give false negatives because even if the value does not change,
682+
// the inner options could still change, so we need to always treat it as reactive
683+
element === 'select' && attribute.value !== true && !is_text_attribute(attribute);
684+
669685
const { value, has_state } = build_attribute_value(attribute.value, context, (value, metadata) =>
670686
metadata.has_call || metadata.is_async
671-
? get_expression_id(metadata.is_async ? state.async_expressions : state.expressions, value)
687+
? // if is a select with value we will also invoke `init_select` which need a reference before the template effect so we memoize separately
688+
is_select_with_value
689+
? memoize_expression(context.state, value)
690+
: get_expression_id(metadata.is_async ? state.async_expressions : state.expressions, value)
672691
: value
673692
);
674693

@@ -682,11 +701,6 @@ function build_element_special_value_attribute(element, node_id, attribute, cont
682701
)
683702
);
684703

685-
const is_select_with_value =
686-
// attribute.metadata.dynamic would give false negatives because even if the value does not change,
687-
// the inner options could still change, so we need to always treat it as reactive
688-
element === 'select' && attribute.value !== true && !is_text_attribute(attribute);
689-
690704
const update = b.stmt(
691705
is_select_with_value
692706
? b.sequence([

0 commit comments

Comments
 (0)