svelte 4.2.18 → 4.2.19

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/compiler.cjs CHANGED
@@ -38844,6 +38844,30 @@ function EachBlock (node, renderer, options) {
38844
38844
  }
38845
38845
  }
38846
38846
 
38847
+ const ATTR_REGEX = /[&"<]/g;
38848
+ const CONTENT_REGEX = /[&<]/g;
38849
+
38850
+ /**
38851
+ * Note: this method is performance sensitive and has been optimized
38852
+ * https://github.com/sveltejs/svelte/pull/5701
38853
+ * @param {unknown} value
38854
+ * @returns {string}
38855
+ */
38856
+ function escape(value, is_attr = false) {
38857
+ const str = String(value);
38858
+ const pattern = is_attr ? ATTR_REGEX : CONTENT_REGEX;
38859
+ pattern.lastIndex = 0;
38860
+ let escaped = '';
38861
+ let last = 0;
38862
+ while (pattern.test(str)) {
38863
+ const i = pattern.lastIndex - 1;
38864
+ const ch = str[i];
38865
+ escaped += str.substring(last, i) + (ch === '&' ? '&amp;' : ch === '"' ? '&quot;' : '&lt;');
38866
+ last = i + 1;
38867
+ }
38868
+ return escaped + str.substring(last);
38869
+ }
38870
+
38847
38871
  /**
38848
38872
  * @param {import('../../../nodes/Attribute.js').default} attribute
38849
38873
  * @returns {import('estree').Expression}
@@ -38879,9 +38903,7 @@ function get_attribute_value(attribute) {
38879
38903
  return attribute.chunks
38880
38904
  .map((chunk) => {
38881
38905
  return chunk.type === 'Text'
38882
- ? /** @type {import('estree').Expression} */ (
38883
- string_literal(chunk.data.replace(regex_double_quotes, '&quot;'))
38884
- )
38906
+ ? /** @type {import('estree').Expression} */ (string_literal(escape(chunk.data, true)))
38885
38907
  : x$1`@escape(${chunk.node}, ${is_textarea_value ? 'false' : 'true'})`;
38886
38908
  })
38887
38909
  .reduce((lhs, rhs) => x$1`${lhs} + ${rhs}`);
@@ -43607,7 +43629,7 @@ function is_used_as_reference(node, parent) {
43607
43629
  * https://svelte.dev/docs/svelte-compiler#svelte-version
43608
43630
  * @type {string}
43609
43631
  */
43610
- const VERSION = '4.2.18';
43632
+ const VERSION = '4.2.19';
43611
43633
 
43612
43634
  const regex_leading_directory_separator = /^[/\\]/;
43613
43635
  const regex_starts_with_term_export = /^Export/;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte",
3
- "version": "4.2.18",
3
+ "version": "4.2.19",
4
4
  "description": "Cybernetically enhanced web apps",
5
5
  "type": "module",
6
6
  "module": "src/runtime/index.js",
@@ -1,6 +1,6 @@
1
1
  import { string_literal } from '../../../utils/stringify.js';
2
2
  import { x } from 'code-red';
3
- import { regex_double_quotes } from '../../../../utils/patterns.js';
3
+ import { escape } from '../../../../../shared/utils/escape.js';
4
4
 
5
5
  /**
6
6
  * @param {import('../../../nodes/Attribute.js').default} attribute
@@ -37,9 +37,7 @@ export function get_attribute_value(attribute) {
37
37
  return attribute.chunks
38
38
  .map((chunk) => {
39
39
  return chunk.type === 'Text'
40
- ? /** @type {import('estree').Expression} */ (
41
- string_literal(chunk.data.replace(regex_double_quotes, '&quot;'))
42
- )
40
+ ? /** @type {import('estree').Expression} */ (string_literal(escape(chunk.data, true)))
43
41
  : x`@escape(${chunk.node}, ${is_textarea_value ? 'false' : 'true'})`;
44
42
  })
45
43
  .reduce((lhs, rhs) => x`${lhs} + ${rhs}`);
@@ -2,7 +2,9 @@ import { set_current_component, current_component } from './lifecycle.js';
2
2
  import { run_all, blank_object } from './utils.js';
3
3
  import { boolean_attributes } from '../../shared/boolean_attributes.js';
4
4
  import { ensure_array_like } from './each.js';
5
+ import { escape } from '../../shared/utils/escape.js';
5
6
  export { is_void } from '../../shared/utils/names.js';
7
+ export { escape };
6
8
 
7
9
  export const invalid_attribute_name_character =
8
10
  /[\s'">/=\u{FDD0}-\u{FDEF}\u{FFFE}\u{FFFF}\u{1FFFE}\u{1FFFF}\u{2FFFE}\u{2FFFF}\u{3FFFE}\u{3FFFF}\u{4FFFE}\u{4FFFF}\u{5FFFE}\u{5FFFF}\u{6FFFE}\u{6FFFF}\u{7FFFE}\u{7FFFF}\u{8FFFE}\u{8FFFF}\u{9FFFE}\u{9FFFF}\u{AFFFE}\u{AFFFF}\u{BFFFE}\u{BFFFF}\u{CFFFE}\u{CFFFF}\u{DFFFE}\u{DFFFF}\u{EFFFE}\u{EFFFF}\u{FFFFE}\u{FFFFF}\u{10FFFE}\u{10FFFF}]/u;
@@ -67,30 +69,6 @@ export function merge_ssr_styles(style_attribute, style_directive) {
67
69
  return style_object;
68
70
  }
69
71
 
70
- const ATTR_REGEX = /[&"]/g;
71
- const CONTENT_REGEX = /[&<]/g;
72
-
73
- /**
74
- * Note: this method is performance sensitive and has been optimized
75
- * https://github.com/sveltejs/svelte/pull/5701
76
- * @param {unknown} value
77
- * @returns {string}
78
- */
79
- export function escape(value, is_attr = false) {
80
- const str = String(value);
81
- const pattern = is_attr ? ATTR_REGEX : CONTENT_REGEX;
82
- pattern.lastIndex = 0;
83
- let escaped = '';
84
- let last = 0;
85
- while (pattern.test(str)) {
86
- const i = pattern.lastIndex - 1;
87
- const ch = str[i];
88
- escaped += str.substring(last, i) + (ch === '&' ? '&amp;' : ch === '"' ? '&quot;' : '&lt;');
89
- last = i + 1;
90
- }
91
- return escaped + str.substring(last);
92
- }
93
-
94
72
  export function escape_attribute_value(value) {
95
73
  // keep booleans, null, and undefined for the sake of `spread`
96
74
  const should_escape = typeof value === 'string' || (value && typeof value === 'object');
@@ -0,0 +1,23 @@
1
+ const ATTR_REGEX = /[&"<]/g;
2
+ const CONTENT_REGEX = /[&<]/g;
3
+
4
+ /**
5
+ * Note: this method is performance sensitive and has been optimized
6
+ * https://github.com/sveltejs/svelte/pull/5701
7
+ * @param {unknown} value
8
+ * @returns {string}
9
+ */
10
+ export function escape(value, is_attr = false) {
11
+ const str = String(value);
12
+ const pattern = is_attr ? ATTR_REGEX : CONTENT_REGEX;
13
+ pattern.lastIndex = 0;
14
+ let escaped = '';
15
+ let last = 0;
16
+ while (pattern.test(str)) {
17
+ const i = pattern.lastIndex - 1;
18
+ const ch = str[i];
19
+ escaped += str.substring(last, i) + (ch === '&' ? '&amp;' : ch === '"' ? '&quot;' : '&lt;');
20
+ last = i + 1;
21
+ }
22
+ return escaped + str.substring(last);
23
+ }
@@ -6,5 +6,5 @@
6
6
  * https://svelte.dev/docs/svelte-compiler#svelte-version
7
7
  * @type {string}
8
8
  */
9
- export const VERSION = '4.2.18';
9
+ export const VERSION = '4.2.19';
10
10
  export const PUBLIC_VERSION = '4';
package/svelte-html.d.ts CHANGED
@@ -243,8 +243,8 @@ declare global {
243
243
  'svelte:body': HTMLProps<'svelte:body', HTMLAttributes>;
244
244
  'svelte:document': HTMLProps<'svelte:document', HTMLAttributes>;
245
245
  'svelte:fragment': { slot?: string };
246
- 'svelte:options': HTMLProps<'svelte:options', HTMLAttributes>;
247
246
  'svelte:head': { [name: string]: any };
247
+ // don't type svelte:options, it would override the types in svelte/elements and it isn't extendable anyway
248
248
 
249
249
  [name: string]: { [name: string]: any };
250
250
  }