svelte 5.3.0 → 5.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "svelte",
3
3
  "description": "Cybernetically enhanced web apps",
4
4
  "license": "MIT",
5
- "version": "5.3.0",
5
+ "version": "5.3.2",
6
6
  "type": "module",
7
7
  "types": "./types/index.d.ts",
8
8
  "engines": {
@@ -201,16 +201,19 @@ function apply_combinator(relative_selector, parent_selectors, rule, node) {
201
201
  const parent = path[i];
202
202
 
203
203
  if (parent.type === 'SnippetBlock') {
204
- if (seen.has(parent)) return true;
205
- seen.add(parent);
204
+ if (seen.has(parent)) {
205
+ parent_matched = true;
206
+ } else {
207
+ seen.add(parent);
206
208
 
207
- for (const site of parent.metadata.sites) {
208
- if (apply_combinator(relative_selector, parent_selectors, rule, site)) {
209
- return true;
209
+ for (const site of parent.metadata.sites) {
210
+ if (apply_combinator(relative_selector, parent_selectors, rule, site)) {
211
+ parent_matched = true;
212
+ }
210
213
  }
211
214
  }
212
215
 
213
- return false;
216
+ break;
214
217
  }
215
218
 
216
219
  if (parent.type === 'RegularElement' || parent.type === 'SvelteElement') {
@@ -51,6 +51,7 @@ import { RenderTag } from './visitors/RenderTag.js';
51
51
  import { SlotElement } from './visitors/SlotElement.js';
52
52
  import { SnippetBlock } from './visitors/SnippetBlock.js';
53
53
  import { SpreadAttribute } from './visitors/SpreadAttribute.js';
54
+ import { SpreadElement } from './visitors/SpreadElement.js';
54
55
  import { StyleDirective } from './visitors/StyleDirective.js';
55
56
  import { SvelteBody } from './visitors/SvelteBody.js';
56
57
  import { SvelteComponent } from './visitors/SvelteComponent.js';
@@ -163,6 +164,7 @@ const visitors = {
163
164
  SlotElement,
164
165
  SnippetBlock,
165
166
  SpreadAttribute,
167
+ SpreadElement,
166
168
  StyleDirective,
167
169
  SvelteBody,
168
170
  SvelteComponent,
@@ -0,0 +1,16 @@
1
+ /** @import { SpreadElement } from 'estree' */
2
+ /** @import { Context } from '../types' */
3
+
4
+ /**
5
+ * @param {SpreadElement} node
6
+ * @param {Context} context
7
+ */
8
+ export function SpreadElement(node, context) {
9
+ if (context.state.expression) {
10
+ // treat e.g. `[...x]` the same as `[...x.values()]`
11
+ context.state.expression.has_call = true;
12
+ context.state.expression.has_state = true;
13
+ }
14
+
15
+ context.next();
16
+ }
@@ -14,13 +14,16 @@ import { build_template } from './shared/utils.js';
14
14
  */
15
15
  export function SvelteElement(node, context) {
16
16
  let tag = /** @type {Expression} */ (context.visit(node.tag));
17
- if (tag.type !== 'Identifier') {
18
- const tag_id = context.state.scope.generate('$$tag');
19
- context.state.init.push(b.const(tag_id, tag));
20
- tag = b.id(tag_id);
21
- }
22
17
 
23
18
  if (dev) {
19
+ // Ensure getters/function calls aren't called multiple times.
20
+ // If we ever start referencing `tag` more than once in prod, move this out of the if block.
21
+ if (tag.type !== 'Identifier') {
22
+ const tag_id = context.state.scope.generate('$$tag');
23
+ context.state.init.push(b.const(tag_id, tag));
24
+ tag = b.id(tag_id);
25
+ }
26
+
24
27
  if (node.fragment.nodes.length > 0) {
25
28
  context.state.init.push(b.stmt(b.call('$.validate_void_dynamic_element', b.thunk(tag))));
26
29
  }
@@ -1068,23 +1068,32 @@ function get_parent_context(component_context) {
1068
1068
  }
1069
1069
 
1070
1070
  /**
1071
- * @param {Value<number>} signal
1071
+ * @template {number | bigint} T
1072
+ * @param {Value<T>} signal
1072
1073
  * @param {1 | -1} [d]
1073
- * @returns {number}
1074
+ * @returns {T}
1074
1075
  */
1075
1076
  export function update(signal, d = 1) {
1076
- var value = +get(signal);
1077
- set(signal, value + d);
1078
- return value;
1077
+ var value = get(signal);
1078
+ var result = d === 1 ? value++ : value--;
1079
+
1080
+ set(signal, value);
1081
+
1082
+ // @ts-expect-error
1083
+ return result;
1079
1084
  }
1080
1085
 
1081
1086
  /**
1082
- * @param {Value<number>} signal
1087
+ * @template {number | bigint} T
1088
+ * @param {Value<T>} signal
1083
1089
  * @param {1 | -1} [d]
1084
- * @returns {number}
1090
+ * @returns {T}
1085
1091
  */
1086
1092
  export function update_pre(signal, d = 1) {
1087
- return set(signal, +get(signal) + d);
1093
+ var value = get(signal);
1094
+
1095
+ // @ts-expect-error
1096
+ return set(signal, d === 1 ? ++value : --value);
1088
1097
  }
1089
1098
 
1090
1099
  /**
@@ -222,11 +222,13 @@ export function spread_attributes(attrs, classes, styles, flags = 0) {
222
222
  if (name[0] === '$' && name[1] === '$') continue; // faster than name.startsWith('$$')
223
223
  if (INVALID_ATTR_NAME_CHAR_REGEX.test(name)) continue;
224
224
 
225
+ var value = attrs[name];
226
+
225
227
  if (lowercase) {
226
228
  name = name.toLowerCase();
227
229
  }
228
230
 
229
- attr_str += attr(name, attrs[name], is_html && is_boolean_attribute(name));
231
+ attr_str += attr(name, value, is_html && is_boolean_attribute(name));
230
232
  }
231
233
 
232
234
  return attr_str;
package/src/version.js CHANGED
@@ -6,5 +6,5 @@
6
6
  * https://svelte.dev/docs/svelte-compiler#svelte-version
7
7
  * @type {string}
8
8
  */
9
- export const VERSION = '5.3.0';
9
+ export const VERSION = '5.3.2';
10
10
  export const PUBLIC_VERSION = '5';