attribute-invalid-sequence-expression
Rich Harris 2 days ago
parent dae07293d4
commit 08bd4e0b80

@ -66,39 +66,25 @@ Event attribute must be a JavaScript expression, not a string
Comma-separated expressions are not allowed as attribute/directive values in runes mode, unless wrapped in parentheses
```
```
An attribute value cannot be a comma-separated sequence of expressions — in other words this is disallowed:
```
```
```svelte
<div class={size, color}>...</div>
```
```
```
Instead, make sure that the attribute value contains a single expression. In the example above it's likely that this was intended (see the [class documentation](class) for more details):
```
```
```svelte
<div class={[size, color]}>...</div>
```
```
```
If you _do_ need to use the comma operator for some reason, wrap the sequence in parentheses:
```
```
```svelte
<div class={(size, color)}>...</div>
```
```
```
[!NOTE] This will evaluate to `color`, ignoring `size`.
```
Note that this will evaluate to `color`, ignoring `size`.
### attribute_invalid_type

@ -60,7 +60,7 @@ If you _do_ need to use the comma operator for some reason, wrap the sequence in
<div class={(size, color)}>...</div>
```
> [!NOTE] This will evaluate to `color`, ignoring `size`.
Note that this will evaluate to `color`, ignoring `size`.
## attribute_invalid_type

@ -785,12 +785,12 @@ export function attribute_invalid_name(node, name) {
}
/**
* [!NOTE] This will evaluate to `color`, ignoring `size`.
* Comma-separated expressions are not allowed as attribute/directive values in runes mode, unless wrapped in parentheses
* @param {null | number | NodeLike} node
* @returns {never}
*/
export function attribute_invalid_sequence_expression(node) {
e(node, 'attribute_invalid_sequence_expression', `[!NOTE] This will evaluate to \`color\`, ignoring \`size\`.\nhttps://svelte.dev/e/attribute_invalid_sequence_expression`);
e(node, 'attribute_invalid_sequence_expression', `Comma-separated expressions are not allowed as attribute/directive values in runes mode, unless wrapped in parentheses\nhttps://svelte.dev/e/attribute_invalid_sequence_expression`);
}
/**

Loading…
Cancel
Save