Skip to content

Commit 726c153

Browse files
committed
Merge branch 'main' into each-without-as
2 parents abdf456 + 6a5f30b commit 726c153

File tree

41 files changed

+318
-325
lines changed

Some content is hidden

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

41 files changed

+318
-325
lines changed

.changeset/unlucky-icons-sit.md

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

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
- [ ] Prefix your PR title with `feat:`, `fix:`, `chore:`, or `docs:`.
55
- [ ] This message body should clearly illustrate what problems it solves.
66
- [ ] Ideally, include a test that fails without this PR but passes with it.
7+
- [ ] If this PR changes code within `packages/svelte/src`, add a changeset (`npx changeset`).
78

89
### Tests and linting
910

documentation/docs/07-misc/03-typescript.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ In case you're writing a component that wraps a native element, you may want to
142142
</script>
143143
144144
<button {...rest}>
145-
{@render children()}
145+
{@render children?.()}
146146
</button>
147147
```
148148

@@ -156,7 +156,7 @@ Not all elements have a dedicated type definition. For those without one, use `S
156156
</script>
157157
158158
<div {...rest}>
159-
{@render children()}
159+
{@render children?.()}
160160
</div>
161161
```
162162

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.2.7
4+
5+
### Patch Changes
6+
7+
- fix: always use set for private identifiers ([#14378](https://github.com/sveltejs/svelte/pull/14378))
8+
9+
## 5.2.6
10+
11+
### Patch Changes
12+
13+
- fix: remove template expression inlining ([#14374](https://github.com/sveltejs/svelte/pull/14374))
14+
15+
## 5.2.5
16+
17+
### Patch Changes
18+
19+
- fix: correctly handle srcObject attribute on video elements ([#14369](https://github.com/sveltejs/svelte/pull/14369))
20+
21+
- add `contentvisibilityautostatechange` event to element definitions ([#14373](https://github.com/sveltejs/svelte/pull/14373))
22+
23+
- fix: tighten up `export default` validation ([#14368](https://github.com/sveltejs/svelte/pull/14368))
24+
25+
- fix: include method definitions in class private fields ([#14365](https://github.com/sveltejs/svelte/pull/14365))
26+
327
## 5.2.4
428

529
### Patch Changes

packages/svelte/elements.d.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ export type AnimationEventHandler<T extends EventTarget> = EventHandler<Animatio
6060
export type TransitionEventHandler<T extends EventTarget> = EventHandler<TransitionEvent, T>;
6161
export type MessageEventHandler<T extends EventTarget> = EventHandler<MessageEvent, T>;
6262
export type ToggleEventHandler<T extends EventTarget> = EventHandler<ToggleEvent, T>;
63+
export type ContentVisibilityAutoStateChangeEventHandler<T extends EventTarget> = EventHandler<
64+
ContentVisibilityAutoStateChangeEvent,
65+
T
66+
>;
6367

6468
export type FullAutoFill =
6569
| AutoFill
@@ -157,6 +161,20 @@ export interface DOMAttributes<T extends EventTarget> {
157161
ontoggle?: ToggleEventHandler<T> | undefined | null;
158162
ontogglecapture?: ToggleEventHandler<T> | undefined | null;
159163

164+
// Content visibility Events
165+
'on:contentvisibilityautostatechange'?:
166+
| ContentVisibilityAutoStateChangeEventHandler<T>
167+
| undefined
168+
| null;
169+
oncontentvisibilityautostatechange?:
170+
| ContentVisibilityAutoStateChangeEventHandler<T>
171+
| undefined
172+
| null;
173+
oncontentvisibilityautostatechangecapture?:
174+
| ContentVisibilityAutoStateChangeEventHandler<T>
175+
| undefined
176+
| null;
177+
160178
// Keyboard Events
161179
'on:keydown'?: KeyboardEventHandler<T> | undefined | null;
162180
onkeydown?: KeyboardEventHandler<T> | undefined | null;

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.2.4",
5+
"version": "5.2.7",
66
"type": "module",
77
"types": "./types/index.d.ts",
88
"engines": {

packages/svelte/src/compiler/phases/2-analyze/visitors/Attribute.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/** @import { ArrowFunctionExpression, Expression, FunctionDeclaration, FunctionExpression } from 'estree' */
22
/** @import { AST, DelegatedEvent, SvelteNode } from '#compiler' */
33
/** @import { Context } from '../types' */
4-
import { is_boolean_attribute, is_capture_event, is_delegated } from '../../../../utils.js';
4+
import { cannot_be_set_statically, is_capture_event, is_delegated } from '../../../../utils.js';
55
import {
66
get_attribute_chunks,
77
get_attribute_expression,
@@ -30,12 +30,12 @@ export function Attribute(node, context) {
3030
}
3131
}
3232

33-
if (node.name.startsWith('on')) {
33+
if (is_event_attribute(node)) {
3434
mark_subtree_dynamic(context.path);
3535
}
3636

37-
if (parent.type === 'RegularElement' && is_boolean_attribute(node.name.toLowerCase())) {
38-
node.metadata.expression.can_inline = false;
37+
if (cannot_be_set_statically(node.name)) {
38+
mark_subtree_dynamic(context.path);
3939
}
4040

4141
if (node.value !== true) {
@@ -51,7 +51,6 @@ export function Attribute(node, context) {
5151

5252
node.metadata.expression.has_state ||= chunk.metadata.expression.has_state;
5353
node.metadata.expression.has_call ||= chunk.metadata.expression.has_call;
54-
node.metadata.expression.can_inline &&= chunk.metadata.expression.can_inline;
5554
}
5655

5756
if (is_event_attribute(node)) {

packages/svelte/src/compiler/phases/2-analyze/visitors/CallExpression.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,6 @@ export function CallExpression(node, context) {
179179
if (!is_pure(node.callee, context) || context.state.expression.dependencies.size > 0) {
180180
context.state.expression.has_call = true;
181181
context.state.expression.has_state = true;
182-
context.state.expression.can_inline = false;
183-
mark_subtree_dynamic(context.path);
184182
}
185183
}
186184
}

packages/svelte/src/compiler/phases/2-analyze/visitors/ExportDefaultDeclaration.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
1-
/** @import { ExportDefaultDeclaration, Node } from 'estree' */
1+
/** @import { ExportDefaultDeclaration } from 'estree' */
22
/** @import { Context } from '../types' */
33
import * as e from '../../../errors.js';
4+
import { validate_export } from './shared/utils.js';
45

56
/**
67
* @param {ExportDefaultDeclaration} node
78
* @param {Context} context
89
*/
910
export function ExportDefaultDeclaration(node, context) {
10-
if (context.state.ast_type === 'instance') {
11+
if (!context.state.ast_type /* .svelte.js module */) {
12+
if (node.declaration.type === 'Identifier') {
13+
validate_export(node, context.state.scope, node.declaration.name);
14+
}
15+
} else {
1116
e.module_illegal_default_export(node);
1217
}
1318

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
/** @import { ExportSpecifier, Node } from 'estree' */
2-
/** @import { Binding } from '#compiler' */
1+
/** @import { ExportSpecifier } from 'estree' */
32
/** @import { Context } from '../types' */
4-
/** @import { Scope } from '../../scope' */
5-
import * as e from '../../../errors.js';
3+
import { validate_export } from './shared/utils.js';
64

75
/**
86
* @param {ExportSpecifier} node
@@ -30,22 +28,3 @@ export function ExportSpecifier(node, context) {
3028
validate_export(node, context.state.scope, local_name);
3129
}
3230
}
33-
34-
/**
35-
*
36-
* @param {Node} node
37-
* @param {Scope} scope
38-
* @param {string} name
39-
*/
40-
function validate_export(node, scope, name) {
41-
const binding = scope.get(name);
42-
if (!binding) return;
43-
44-
if (binding.kind === 'derived') {
45-
e.derived_invalid_export(node);
46-
}
47-
48-
if ((binding.kind === 'state' || binding.kind === 'raw_state') && binding.reassigned) {
49-
e.state_invalid_export(node);
50-
}
51-
}

0 commit comments

Comments
 (0)