Skip to content

Commit 93d70d7

Browse files
Merge branch 'main' into ssr-select-value
2 parents 7df4505 + 2e27c5d commit 93d70d7

File tree

17 files changed

+137
-15
lines changed

17 files changed

+137
-15
lines changed

.changeset/olive-pandas-trade.md

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

.changeset/thin-dolls-cover.md

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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: bind:
44

55
Data ordinarily flows down, from parent to child. The `bind:` directive allows data to flow the other way, from child to parent.
66

7-
The general syntax is `bind:property={expression}`, where `expression` is an _lvalue_ (i.e. a variable or an object property). When the expression is an identifier with the same name as the property, we can omit the expression — in other words these are equivalent:
7+
The general syntax is `bind:property={expression}`, where `expression` is an [_lvalue_](https://press.rebus.community/programmingfundamentals/chapter/lvalue-and-rvalue/) (i.e. a variable or an object property). When the expression is an identifier with the same name as the property, we can omit the expression — in other words these are equivalent:
88

99
<!-- prettier-ignore -->
1010
```svelte

documentation/docs/98-reference/.generated/compile-warnings.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,12 @@ In some situations a selector may target an element that is not 'visible' to the
632632
</style>
633633
```
634634

635+
### custom_element_props_identifier
636+
637+
```
638+
Using a rest element or a non-destructured declaration with `$props()` means that Svelte can't infer what properties to expose when creating a custom element. Consider destructuring all the props or explicitly specifying the `customElement.props` option.
639+
```
640+
635641
### element_implicitly_closed
636642

637643
```

packages/svelte/CHANGELOG.md

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

3+
## 5.33.4
4+
5+
### Patch Changes
6+
7+
- fix: narrow `defaultChecked` to boolean ([#16009](https://github.com/sveltejs/svelte/pull/16009))
8+
9+
- fix: warn when using rest or identifier in custom elements without props option ([#16003](https://github.com/sveltejs/svelte/pull/16003))
10+
11+
## 5.33.3
12+
13+
### Patch Changes
14+
15+
- fix: allow using typescript in `customElement.extend` option ([#16001](https://github.com/sveltejs/svelte/pull/16001))
16+
17+
- fix: cleanup event handlers on media elements ([#16005](https://github.com/sveltejs/svelte/pull/16005))
18+
319
## 5.33.2
420

521
### Patch Changes

packages/svelte/elements.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,8 +1115,8 @@ export interface HTMLInputAttributes extends HTMLAttributes<HTMLInputElement> {
11151115
// needs both casing variants because language tools does lowercase names of non-shorthand attributes
11161116
defaultValue?: any;
11171117
defaultvalue?: any;
1118-
defaultChecked?: any;
1119-
defaultchecked?: any;
1118+
defaultChecked?: boolean | undefined | null;
1119+
defaultchecked?: boolean | undefined | null;
11201120
width?: number | string | undefined | null;
11211121
webkitdirectory?: boolean | undefined | null;
11221122

packages/svelte/messages/compile-warnings/script.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## custom_element_props_identifier
2+
3+
> Using a rest element or a non-destructured declaration with `$props()` means that Svelte can't infer what properties to expose when creating a custom element. Consider destructuring all the props or explicitly specifying the `customElement.props` option.
4+
15
## export_let_unused
26

37
> Component has unused export property '%name%'. If it is for external reference only, please consider using `export const %name%`

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

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import { get_rune } from '../../scope.js';
55
import { ensure_no_module_import_conflict, validate_identifier_name } from './shared/utils.js';
66
import * as e from '../../../errors.js';
7+
import * as w from '../../../warnings.js';
78
import { extract_paths } from '../../../utils/ast.js';
89
import { equal } from '../../../utils/assert.js';
910

@@ -52,6 +53,19 @@ export function VariableDeclarator(node, context) {
5253
e.props_invalid_identifier(node);
5354
}
5455

56+
if (
57+
context.state.analysis.custom_element &&
58+
context.state.options.customElementOptions?.props == null
59+
) {
60+
let warn_on;
61+
if (
62+
node.id.type === 'Identifier' ||
63+
(warn_on = node.id.properties.find((p) => p.type === 'RestElement')) != null
64+
) {
65+
w.custom_element_props_identifier(warn_on ?? node.id);
66+
}
67+
}
68+
5569
context.state.analysis.needs_props = true;
5670

5771
if (node.id.type === 'Identifier') {

packages/svelte/src/compiler/warnings.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ export const codes = [
9696
'options_removed_hydratable',
9797
'options_removed_loop_guard_timeout',
9898
'options_renamed_ssr_dom',
99+
'custom_element_props_identifier',
99100
'export_let_unused',
100101
'legacy_component_creation',
101102
'non_reactive_update',
@@ -592,6 +593,14 @@ export function options_renamed_ssr_dom(node) {
592593
w(node, 'options_renamed_ssr_dom', `\`generate: "dom"\` and \`generate: "ssr"\` options have been renamed to "client" and "server" respectively\nhttps://svelte.dev/e/options_renamed_ssr_dom`);
593594
}
594595

596+
/**
597+
* Using a rest element or a non-destructured declaration with `$props()` means that Svelte can't infer what properties to expose when creating a custom element. Consider destructuring all the props or explicitly specifying the `customElement.props` option.
598+
* @param {null | NodeLike} node
599+
*/
600+
export function custom_element_props_identifier(node) {
601+
w(node, 'custom_element_props_identifier', `Using a rest element or a non-destructured declaration with \`$props()\` means that Svelte can't infer what properties to expose when creating a custom element. Consider destructuring all the props or explicitly specifying the \`customElement.props\` option.\nhttps://svelte.dev/e/custom_element_props_identifier`);
602+
}
603+
595604
/**
596605
* Component has unused export property '%name%'. If it is for external reference only, please consider using `export const %name%`
597606
* @param {null | NodeLike} node

0 commit comments

Comments
 (0)