Merge branch 'main' into ssr-select-value

pull/16017/head
Paolo Ricciuti 4 months ago committed by GitHub
commit 93d70d76ea
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -1,5 +0,0 @@
---
'svelte': patch
---
fix: allow using typescript in `customElement.extend` option

@ -1,5 +0,0 @@
---
'svelte': patch
---
fix: cleanup event handlers on media elements

@ -4,7 +4,7 @@ title: bind:
Data ordinarily flows down, from parent to child. The `bind:` directive allows data to flow the other way, from child to parent. Data ordinarily flows down, from parent to child. The `bind:` directive allows data to flow the other way, from child to parent.
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: 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:
<!-- prettier-ignore --> <!-- prettier-ignore -->
```svelte ```svelte

@ -632,6 +632,12 @@ In some situations a selector may target an element that is not 'visible' to the
</style> </style>
``` ```
### 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.
```
### element_implicitly_closed ### element_implicitly_closed
``` ```

@ -1,5 +1,21 @@
# svelte # svelte
## 5.33.4
### Patch Changes
- fix: narrow `defaultChecked` to boolean ([#16009](https://github.com/sveltejs/svelte/pull/16009))
- fix: warn when using rest or identifier in custom elements without props option ([#16003](https://github.com/sveltejs/svelte/pull/16003))
## 5.33.3
### Patch Changes
- fix: allow using typescript in `customElement.extend` option ([#16001](https://github.com/sveltejs/svelte/pull/16001))
- fix: cleanup event handlers on media elements ([#16005](https://github.com/sveltejs/svelte/pull/16005))
## 5.33.2 ## 5.33.2
### Patch Changes ### Patch Changes

@ -1115,8 +1115,8 @@ export interface HTMLInputAttributes extends HTMLAttributes<HTMLInputElement> {
// needs both casing variants because language tools does lowercase names of non-shorthand attributes // needs both casing variants because language tools does lowercase names of non-shorthand attributes
defaultValue?: any; defaultValue?: any;
defaultvalue?: any; defaultvalue?: any;
defaultChecked?: any; defaultChecked?: boolean | undefined | null;
defaultchecked?: any; defaultchecked?: boolean | undefined | null;
width?: number | string | undefined | null; width?: number | string | undefined | null;
webkitdirectory?: boolean | undefined | null; webkitdirectory?: boolean | undefined | null;

@ -1,3 +1,7 @@
## 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.
## export_let_unused ## export_let_unused
> Component has unused export property '%name%'. If it is for external reference only, please consider using `export const %name%` > Component has unused export property '%name%'. If it is for external reference only, please consider using `export const %name%`

@ -2,7 +2,7 @@
"name": "svelte", "name": "svelte",
"description": "Cybernetically enhanced web apps", "description": "Cybernetically enhanced web apps",
"license": "MIT", "license": "MIT",
"version": "5.33.2", "version": "5.33.4",
"type": "module", "type": "module",
"types": "./types/index.d.ts", "types": "./types/index.d.ts",
"engines": { "engines": {

@ -4,6 +4,7 @@
import { get_rune } from '../../scope.js'; import { get_rune } from '../../scope.js';
import { ensure_no_module_import_conflict, validate_identifier_name } from './shared/utils.js'; import { ensure_no_module_import_conflict, validate_identifier_name } from './shared/utils.js';
import * as e from '../../../errors.js'; import * as e from '../../../errors.js';
import * as w from '../../../warnings.js';
import { extract_paths } from '../../../utils/ast.js'; import { extract_paths } from '../../../utils/ast.js';
import { equal } from '../../../utils/assert.js'; import { equal } from '../../../utils/assert.js';
@ -52,6 +53,19 @@ export function VariableDeclarator(node, context) {
e.props_invalid_identifier(node); e.props_invalid_identifier(node);
} }
if (
context.state.analysis.custom_element &&
context.state.options.customElementOptions?.props == null
) {
let warn_on;
if (
node.id.type === 'Identifier' ||
(warn_on = node.id.properties.find((p) => p.type === 'RestElement')) != null
) {
w.custom_element_props_identifier(warn_on ?? node.id);
}
}
context.state.analysis.needs_props = true; context.state.analysis.needs_props = true;
if (node.id.type === 'Identifier') { if (node.id.type === 'Identifier') {

@ -96,6 +96,7 @@ export const codes = [
'options_removed_hydratable', 'options_removed_hydratable',
'options_removed_loop_guard_timeout', 'options_removed_loop_guard_timeout',
'options_renamed_ssr_dom', 'options_renamed_ssr_dom',
'custom_element_props_identifier',
'export_let_unused', 'export_let_unused',
'legacy_component_creation', 'legacy_component_creation',
'non_reactive_update', 'non_reactive_update',
@ -592,6 +593,14 @@ export function options_renamed_ssr_dom(node) {
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`); 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`);
} }
/**
* 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.
* @param {null | NodeLike} node
*/
export function custom_element_props_identifier(node) {
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`);
}
/** /**
* Component has unused export property '%name%'. If it is for external reference only, please consider using `export const %name%` * Component has unused export property '%name%'. If it is for external reference only, please consider using `export const %name%`
* @param {null | NodeLike} node * @param {null | NodeLike} node

@ -4,5 +4,5 @@
* The current version, as set in package.json. * The current version, as set in package.json.
* @type {string} * @type {string}
*/ */
export const VERSION = '5.33.2'; export const VERSION = '5.33.4';
export const PUBLIC_VERSION = '5'; export const PUBLIC_VERSION = '5';

@ -0,0 +1,7 @@
<svelte:options customElement={{
props: {}
}} />
<script>
let props = $props();
</script>

@ -0,0 +1,14 @@
[
{
"code": "options_missing_custom_element",
"end": {
"column": 2,
"line": 3
},
"message": "The `customElement` option is used when generating a custom element. Did you forget the `customElement: true` compile option?",
"start": {
"column": 16,
"line": 1
}
}
]

@ -0,0 +1,5 @@
<svelte:options customElement={{}} />
<script>
let { ...props } = $props();
</script>

@ -0,0 +1,26 @@
[
{
"code": "options_missing_custom_element",
"end": {
"column": 34,
"line": 1
},
"message": "The `customElement` option is used when generating a custom element. Did you forget the `customElement: true` compile option?",
"start": {
"column": 16,
"line": 1
}
},
{
"code": "custom_element_props_identifier",
"end": {
"column": 15,
"line": 4
},
"message": "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.",
"start": {
"column": 7,
"line": 4
}
}
]

@ -0,0 +1,5 @@
<svelte:options customElement={{}} />
<script>
let props = $props();
</script>

@ -0,0 +1,26 @@
[
{
"code": "options_missing_custom_element",
"end": {
"column": 34,
"line": 1
},
"message": "The `customElement` option is used when generating a custom element. Did you forget the `customElement: true` compile option?",
"start": {
"column": 16,
"line": 1
}
},
{
"code": "custom_element_props_identifier",
"end": {
"column": 10,
"line": 4
},
"message": "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.",
"start": {
"column": 5,
"line": 4
}
}
]
Loading…
Cancel
Save