svelte 5.58.1 → 5.59.0

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.
Files changed (86) hide show
  1. package/compiler/index.js +1 -1
  2. package/package.json +19 -1
  3. package/renderer.d.ts +1 -0
  4. package/src/compiler/errors.js +19 -0
  5. package/src/compiler/index.js +37 -2
  6. package/src/compiler/migrate/index.js +2 -1
  7. package/src/compiler/phases/1-parse/read/options.js +20 -0
  8. package/src/compiler/phases/2-analyze/index.js +21 -2
  9. package/src/compiler/phases/2-analyze/visitors/AnimateDirective.js +5 -0
  10. package/src/compiler/phases/2-analyze/visitors/Attribute.js +6 -2
  11. package/src/compiler/phases/2-analyze/visitors/BindDirective.js +4 -0
  12. package/src/compiler/phases/2-analyze/visitors/ExpressionTag.js +2 -1
  13. package/src/compiler/phases/2-analyze/visitors/HtmlTag.js +5 -0
  14. package/src/compiler/phases/2-analyze/visitors/OnDirective.js +6 -0
  15. package/src/compiler/phases/2-analyze/visitors/RegularElement.js +13 -6
  16. package/src/compiler/phases/2-analyze/visitors/SvelteBody.js +5 -0
  17. package/src/compiler/phases/2-analyze/visitors/SvelteDocument.js +5 -0
  18. package/src/compiler/phases/2-analyze/visitors/SvelteElement.js +5 -1
  19. package/src/compiler/phases/2-analyze/visitors/SvelteHead.js +5 -0
  20. package/src/compiler/phases/2-analyze/visitors/SvelteWindow.js +5 -0
  21. package/src/compiler/phases/2-analyze/visitors/Text.js +3 -1
  22. package/src/compiler/phases/2-analyze/visitors/TransitionDirective.js +6 -0
  23. package/src/compiler/phases/2-analyze/visitors/shared/element.js +3 -2
  24. package/src/compiler/phases/3-transform/client/transform-client.js +68 -1
  25. package/src/compiler/phases/3-transform/client/transform-template/index.js +4 -3
  26. package/src/compiler/phases/3-transform/client/transform-template/template.js +1 -1
  27. package/src/compiler/phases/3-transform/client/visitors/RegularElement.js +23 -13
  28. package/src/compiler/phases/3-transform/client/visitors/RenderTag.js +13 -1
  29. package/src/compiler/phases/3-transform/client/visitors/SnippetBlock.js +11 -1
  30. package/src/compiler/phases/3-transform/client/visitors/SvelteBoundary.js +8 -5
  31. package/src/compiler/phases/3-transform/client/visitors/shared/component.js +17 -8
  32. package/src/compiler/phases/3-transform/client/visitors/shared/element.js +4 -3
  33. package/src/compiler/phases/3-transform/client/visitors/shared/fragment.js +7 -1
  34. package/src/compiler/phases/3-transform/server/transform-server.js +14 -1
  35. package/src/compiler/phases/3-transform/server/visitors/RegularElement.js +8 -4
  36. package/src/compiler/state.js +12 -0
  37. package/src/compiler/utils/builders.js +2 -2
  38. package/src/compiler/validate-options.js +47 -1
  39. package/src/internal/client/constants.js +7 -0
  40. package/src/internal/client/custom-renderer/containers.js +213 -0
  41. package/src/internal/client/custom-renderer/cross.js +145 -0
  42. package/src/internal/client/custom-renderer/index.js +28 -0
  43. package/src/internal/client/custom-renderer/state.js +59 -0
  44. package/src/internal/client/dev/css.js +3 -1
  45. package/src/internal/client/dev/elements.js +9 -7
  46. package/src/internal/client/dev/validation.js +2 -1
  47. package/src/internal/client/dom/blocks/await.js +3 -2
  48. package/src/internal/client/dom/blocks/boundary.js +41 -24
  49. package/src/internal/client/dom/blocks/branches.js +83 -57
  50. package/src/internal/client/dom/blocks/css-props.js +31 -3
  51. package/src/internal/client/dom/blocks/each.js +78 -32
  52. package/src/internal/client/dom/blocks/html.js +19 -13
  53. package/src/internal/client/dom/blocks/slot.js +3 -3
  54. package/src/internal/client/dom/blocks/snippet.js +52 -3
  55. package/src/internal/client/dom/blocks/svelte-element.js +17 -6
  56. package/src/internal/client/dom/blocks/svelte-head.js +13 -4
  57. package/src/internal/client/dom/css.js +4 -4
  58. package/src/internal/client/dom/elements/attributes.js +89 -50
  59. package/src/internal/client/dom/elements/bindings/select.js +11 -2
  60. package/src/internal/client/dom/elements/class.js +16 -5
  61. package/src/internal/client/dom/elements/events.js +126 -19
  62. package/src/internal/client/dom/elements/misc.js +3 -2
  63. package/src/internal/client/dom/elements/style.js +17 -6
  64. package/src/internal/client/dom/hydration.js +6 -6
  65. package/src/internal/client/dom/operations.js +433 -11
  66. package/src/internal/client/dom/reconciler.js +2 -2
  67. package/src/internal/client/dom/template.js +94 -66
  68. package/src/internal/client/errors.js +67 -0
  69. package/src/internal/client/index.js +9 -1
  70. package/src/internal/client/reactivity/async.js +10 -0
  71. package/src/internal/client/reactivity/batch.js +22 -1
  72. package/src/internal/client/reactivity/effects.js +44 -27
  73. package/src/internal/client/render.js +50 -88
  74. package/src/internal/client/runtime.js +6 -1
  75. package/src/internal/disclose-version.js +1 -1
  76. package/src/internal/flags/custom-renderer-server.js +10 -0
  77. package/src/internal/flags/custom-renderer.js +3 -0
  78. package/src/internal/flags/index.js +6 -0
  79. package/src/internal/init-operations.js +3 -0
  80. package/src/internal/shared/errors.js +20 -0
  81. package/src/legacy/legacy-client.js +6 -2
  82. package/src/renderer/index-server.js +18 -0
  83. package/src/renderer/index.js +2 -0
  84. package/src/version.js +1 -1
  85. package/types/index.d.ts +244 -24
  86. package/types/index.d.ts.map +10 -1
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.58.1",
5
+ "version": "5.59.0",
6
6
  "type": "module",
7
7
  "types": "./types/index.d.ts",
8
8
  "engines": {
@@ -22,6 +22,7 @@
22
22
  "exports": {
23
23
  ".": {
24
24
  "types": "./types/index.d.ts",
25
+ "svelte-custom-renderer": "./src/index-client.js",
25
26
  "worker": "./src/index-server.js",
26
27
  "browser": "./src/index-client.js",
27
28
  "default": "./src/index-server.js"
@@ -59,6 +60,9 @@
59
60
  "./internal/disclose-version": {
60
61
  "default": "./src/internal/disclose-version.js"
61
62
  },
63
+ "./internal/init-operations": {
64
+ "default": "./src/internal/init-operations.js"
65
+ },
62
66
  "./internal/flags/async": {
63
67
  "default": "./src/internal/flags/async.js"
64
68
  },
@@ -68,11 +72,17 @@
68
72
  "./internal/flags/tracing": {
69
73
  "default": "./src/internal/flags/tracing.js"
70
74
  },
75
+ "./internal/flags/custom-renderer": {
76
+ "svelte-custom-renderer": "./src/internal/flags/custom-renderer.js",
77
+ "browser": "./src/internal/flags/custom-renderer.js",
78
+ "default": "./src/internal/flags/custom-renderer-server.js"
79
+ },
71
80
  "./internal/server": {
72
81
  "default": "./src/internal/server/index.js"
73
82
  },
74
83
  "./legacy": {
75
84
  "types": "./types/index.d.ts",
85
+ "svelte-custom-renderer": "./src/legacy/legacy-client.js",
76
86
  "worker": "./src/legacy/legacy-server.js",
77
87
  "browser": "./src/legacy/legacy-client.js",
78
88
  "default": "./src/legacy/legacy-server.js"
@@ -83,6 +93,7 @@
83
93
  },
84
94
  "./reactivity": {
85
95
  "types": "./types/index.d.ts",
96
+ "svelte-custom-renderer": "./src/reactivity/index-client.js",
86
97
  "worker": "./src/reactivity/index-server.js",
87
98
  "browser": "./src/reactivity/index-client.js",
88
99
  "default": "./src/reactivity/index-server.js"
@@ -91,12 +102,19 @@
91
102
  "types": "./types/index.d.ts",
92
103
  "default": "./src/reactivity/window/index.js"
93
104
  },
105
+ "./renderer": {
106
+ "types": "./types/index.d.ts",
107
+ "svelte-custom-renderer": "./src/renderer/index.js",
108
+ "browser": "./src/renderer/index.js",
109
+ "default": "./src/renderer/index-server.js"
110
+ },
94
111
  "./server": {
95
112
  "types": "./types/index.d.ts",
96
113
  "default": "./src/server/index.js"
97
114
  },
98
115
  "./store": {
99
116
  "types": "./types/index.d.ts",
117
+ "svelte-custom-renderer": "./src/store/index-client.js",
100
118
  "worker": "./src/store/index-server.js",
101
119
  "browser": "./src/store/index-client.js",
102
120
  "default": "./src/store/index-server.js"
package/renderer.d.ts ADDED
@@ -0,0 +1 @@
1
+ import './types/index.js';
@@ -1194,6 +1194,16 @@ export function illegal_element_attribute(node, name) {
1194
1194
  e(node, 'illegal_element_attribute', `\`<${name}>\` does not support non-event attributes or spread attributes\nhttps://svelte.dev/e/illegal_element_attribute`);
1195
1195
  }
1196
1196
 
1197
+ /**
1198
+ * %message% is not compatible with `customRenderer`
1199
+ * @param {null | number | NodeLike} node
1200
+ * @param {string} message
1201
+ * @returns {never}
1202
+ */
1203
+ export function incompatible_with_custom_renderer(node, message) {
1204
+ e(node, 'incompatible_with_custom_renderer', `${message} is not compatible with \`customRenderer\`\nhttps://svelte.dev/e/incompatible_with_custom_renderer`);
1205
+ }
1206
+
1197
1207
  /**
1198
1208
  * %message%
1199
1209
  * @param {null | number | NodeLike} node
@@ -1549,6 +1559,15 @@ export function svelte_meta_invalid_tag(node, list) {
1549
1559
  e(node, 'svelte_meta_invalid_tag', `Valid \`<svelte:...>\` tag names are ${list}\nhttps://svelte.dev/e/svelte_meta_invalid_tag`);
1550
1560
  }
1551
1561
 
1562
+ /**
1563
+ * `customRenderer` cannot be set in `<svelte:options>` unless the `experimental.customRenderer` compiler option is enabled
1564
+ * @param {null | number | NodeLike} node
1565
+ * @returns {never}
1566
+ */
1567
+ export function svelte_options_customrenderer_disabled(node) {
1568
+ e(node, 'svelte_options_customrenderer_disabled', `\`customRenderer\` cannot be set in \`<svelte:options>\` unless the \`experimental.customRenderer\` compiler option is enabled\nhttps://svelte.dev/e/svelte_options_customrenderer_disabled`);
1569
+ }
1570
+
1552
1571
  /**
1553
1572
  * "tag" option is deprecated — use "customElement" instead
1554
1573
  * @param {null | number | NodeLike} node
@@ -10,6 +10,7 @@ import { analyze_component, analyze_module } from './phases/2-analyze/index.js';
10
10
  import { transform_component, transform_module } from './phases/3-transform/index.js';
11
11
  import { validate_component_options, validate_module_options } from './validate-options.js';
12
12
  import * as state from './state.js';
13
+ import * as e from './errors.js';
13
14
  export { default as preprocess } from './preprocess/index.js';
14
15
  export { print } from './print/index.js';
15
16
 
@@ -28,7 +29,37 @@ export function compile(source, options) {
28
29
 
29
30
  let parsed = _parse(source);
30
31
 
31
- const { customElement: customElementOptions, ...parsed_options } = parsed.options || {};
32
+ const {
33
+ customElement: customElementOptions,
34
+ customRenderer: custom_renderer,
35
+ ...parsed_options
36
+ } = parsed.options || {};
37
+
38
+ // resolve the per-component custom renderer, taking `<svelte:options customRenderer={...} />`
39
+ // into account. The normalized option is always a function returning `string | null | undefined`
40
+ // (see `validate-options.js`). A string opts in to a specific renderer module, `null`
41
+ // opts out to plain DOM (while keeping the feature enabled) and an absent option inherits whatever
42
+ // the global option resolves to.
43
+ let custom_renderer_option = validated.experimental.customRenderer;
44
+
45
+ if (custom_renderer !== undefined) {
46
+ // the feature is a global compiler option — a component can only override the renderer it uses
47
+ // (or opt out) when `experimental.customRenderer` is enabled. Otherwise nothing pushes a
48
+ // renderer, so allowing `<svelte:options customRenderer>` would silently do the wrong thing.
49
+ if (!options.experimental?.customRenderer && parsed.options?.attributes) {
50
+ for (const attribute of parsed.options.attributes) {
51
+ if (attribute.name === 'customRenderer') {
52
+ e.svelte_options_customrenderer_disabled(attribute);
53
+ }
54
+ }
55
+ }
56
+
57
+ if (typeof custom_renderer === 'string') {
58
+ custom_renderer_option = () => custom_renderer;
59
+ } else if (custom_renderer === null) {
60
+ custom_renderer_option = () => null;
61
+ }
62
+ }
32
63
 
33
64
  /** @type {ValidatedCompileOptions} */
34
65
  const combined_options = {
@@ -36,7 +67,11 @@ export function compile(source, options) {
36
67
  ...parsed_options,
37
68
  customElementOptions,
38
69
  css: 'css' in parsed_options ? () => parsed_options.css ?? 'external' : validated.css,
39
- runes: 'runes' in parsed_options ? () => parsed_options.runes : validated.runes
70
+ runes: 'runes' in parsed_options ? () => parsed_options.runes : validated.runes,
71
+ experimental: {
72
+ ...validated.experimental,
73
+ customRenderer: custom_renderer_option
74
+ }
40
75
  };
41
76
 
42
77
  if (parsed.metadata.ts) {
@@ -149,7 +149,8 @@ export function migrate(source, { filename, use_ts } = {}) {
149
149
  css: 'css' in parsed_options ? () => parsed_options.css ?? 'external' : () => 'external',
150
150
  runes: 'runes' in parsed_options ? () => parsed_options.runes : () => undefined,
151
151
  experimental: {
152
- async: true
152
+ async: true,
153
+ customRenderer: () => undefined
153
154
  }
154
155
  };
155
156
 
@@ -36,6 +36,26 @@ export default function read_options(node) {
36
36
  e.svelte_options_deprecated_tag(attribute);
37
37
  break; // eslint doesn't know this is unnecessary
38
38
  }
39
+ case 'customRenderer': {
40
+ const { value } = attribute;
41
+ const chunk = Array.isArray(value) ? value[0] : value;
42
+
43
+ if (chunk === true || !chunk || (Array.isArray(value) && value.length !== 1)) {
44
+ e.svelte_options_invalid_attribute_value(attribute, 'a string or null');
45
+ }
46
+
47
+ if (chunk.type === 'Text') {
48
+ component_options.customRenderer = chunk.data;
49
+ } else if (
50
+ chunk.expression?.type === 'Literal' &&
51
+ (typeof chunk.expression.value === 'string' || chunk.expression.value === null)
52
+ ) {
53
+ component_options.customRenderer = chunk.expression.value;
54
+ } else {
55
+ e.svelte_options_invalid_attribute_value(attribute, 'a string or null');
56
+ }
57
+ break;
58
+ }
39
59
  case 'customElement': {
40
60
  /** @type {AST.SvelteOptions['customElement']} */
41
61
  const ce = {};
@@ -471,6 +471,24 @@ export function analyze_component(root, source, options) {
471
471
 
472
472
  const custom_element_from_option = options.customElement({ filename: options.filename });
473
473
  const css = options.css({ filename: options.filename });
474
+ const custom_renderer = options.experimental.customRenderer({ filename: options.filename });
475
+
476
+ // Injected styles are added to the document, which doesn't apply to components that use a
477
+ // custom renderer (an actual renderer module, i.e. a string — `null` means the DOM): they are
478
+ // never server-rendered and their nodes aren't in the document. An inherited `css: 'injected'`
479
+ // (from the compiler options, which tools like vite-plugin-svelte set) is therefore ignored and
480
+ // the CSS is returned as with `css: 'external'`; only an explicit `<svelte:options css="injected" />`
481
+ // in such a component is an error
482
+ const has_custom_renderer = typeof custom_renderer === 'string';
483
+
484
+ if (has_custom_renderer) {
485
+ const css_attribute = root.options?.attributes.find((attribute) => attribute.name === 'css');
486
+
487
+ if (css_attribute) {
488
+ e.incompatible_with_custom_renderer(css_attribute, "`css: 'injected'`");
489
+ }
490
+ }
491
+
474
492
  const custom_element = options.customElementOptions ?? custom_element_from_option;
475
493
  const is_custom_element = !!options.customElementOptions || custom_element_from_option;
476
494
 
@@ -480,7 +498,8 @@ export function analyze_component(root, source, options) {
480
498
  component_name: name,
481
499
  dev: options.dev,
482
500
  rootDir: options.rootDir,
483
- runes
501
+ runes,
502
+ custom_renderer: custom_renderer
484
503
  });
485
504
 
486
505
  // TODO remove all the ?? stuff, we don't need it now that we're validating the config
@@ -533,7 +552,7 @@ export function analyze_component(root, source, options) {
533
552
  event_directive_node: null,
534
553
  uses_event_attributes: false,
535
554
  custom_element,
536
- inject_styles: css === 'injected' || is_custom_element,
555
+ inject_styles: (css === 'injected' && !has_custom_renderer) || is_custom_element,
537
556
  accessors:
538
557
  is_custom_element ||
539
558
  (runes ? false : !!options.accessors) ||
@@ -1,12 +1,17 @@
1
1
  /** @import { Context } from '../types' */
2
2
  /** @import { AST } from '#compiler'; */
3
3
  import * as e from '../../../errors.js';
4
+ import { custom_renderer } from '../../../state.js';
4
5
 
5
6
  /**
6
7
  * @param {AST.AnimateDirective} node
7
8
  * @param {Context} context
8
9
  */
9
10
  export function AnimateDirective(node, context) {
11
+ if (custom_renderer) {
12
+ e.incompatible_with_custom_renderer(node, '`animate:`');
13
+ }
14
+
10
15
  context.next({ ...context.state, expression: node.metadata.expression });
11
16
 
12
17
  if (node.metadata.expression.has_await) {
@@ -2,6 +2,7 @@
2
2
  /** @import { Context } from '../types' */
3
3
  import { cannot_be_set_statically, can_delegate_event } from '../../../../utils.js';
4
4
  import { get_attribute_chunks, is_event_attribute } from '../../../utils/ast.js';
5
+ import { custom_renderer } from '../../../state.js';
5
6
  import { mark_subtree_dynamic } from './shared/fragment.js';
6
7
 
7
8
  /**
@@ -59,8 +60,11 @@ export function Attribute(node, context) {
59
60
  context.state.analysis.uses_event_attributes = true;
60
61
  }
61
62
 
62
- node.metadata.delegated =
63
- parent?.type === 'RegularElement' && can_delegate_event(node.name.slice(2));
63
+ // we can't delegate event handlers in a non dom environment
64
+ if (!custom_renderer) {
65
+ node.metadata.delegated =
66
+ parent?.type === 'RegularElement' && can_delegate_event(node.name.slice(2));
67
+ }
64
68
  }
65
69
  }
66
70
  }
@@ -12,6 +12,7 @@ import { binding_properties } from '../../bindings.js';
12
12
  import fuzzymatch from '../../../utils/fuzzymatch.js';
13
13
  import { is_content_editable_binding, is_svg } from '../../../../utils.js';
14
14
  import { mark_subtree_dynamic } from './shared/fragment.js';
15
+ import { custom_renderer } from '../../../state.js';
15
16
 
16
17
  /**
17
18
  * @param {AST.BindDirective} node
@@ -27,6 +28,9 @@ export function BindDirective(node, context) {
27
28
  parent?.type === 'SvelteDocument' ||
28
29
  parent?.type === 'SvelteBody'
29
30
  ) {
31
+ if (custom_renderer) {
32
+ e.incompatible_with_custom_renderer(node, '`bind:`');
33
+ }
30
34
  if (node.name in binding_properties) {
31
35
  const property = binding_properties[node.name];
32
36
  if (property.valid_elements && !property.valid_elements.includes(parent.name)) {
@@ -2,6 +2,7 @@
2
2
  /** @import { Context } from '../types' */
3
3
  import { is_tag_valid_with_parent } from '../../../../html-tree-validation.js';
4
4
  import * as e from '../../../errors.js';
5
+ import { custom_renderer } from '../../../state.js';
5
6
  import { mark_subtree_dynamic } from './shared/fragment.js';
6
7
 
7
8
  /**
@@ -11,7 +12,7 @@ import { mark_subtree_dynamic } from './shared/fragment.js';
11
12
  export function ExpressionTag(node, context) {
12
13
  const in_template = context.path.at(-1)?.type === 'Fragment';
13
14
 
14
- if (in_template && context.state.parent_element) {
15
+ if (in_template && context.state.parent_element && !custom_renderer) {
15
16
  const message = is_tag_valid_with_parent('#text', context.state.parent_element);
16
17
  if (message) {
17
18
  e.node_invalid_placement(node, message);
@@ -2,12 +2,17 @@
2
2
  /** @import { Context } from '../types' */
3
3
  import { mark_subtree_dynamic } from './shared/fragment.js';
4
4
  import { validate_opening_tag } from './shared/utils.js';
5
+ import * as e from '../../../errors.js';
6
+ import { custom_renderer } from '../../../state.js';
5
7
 
6
8
  /**
7
9
  * @param {AST.HtmlTag} node
8
10
  * @param {Context} context
9
11
  */
10
12
  export function HtmlTag(node, context) {
13
+ if (custom_renderer) {
14
+ e.incompatible_with_custom_renderer(node, '`@html`');
15
+ }
11
16
  if (context.state.analysis.runes) {
12
17
  validate_opening_tag(node, context.state, '@');
13
18
  }
@@ -1,6 +1,8 @@
1
1
  /** @import { AST } from '#compiler' */
2
2
  /** @import { Context } from '../types' */
3
+ import * as e from '../../../errors.js';
3
4
  import * as w from '../../../warnings.js';
5
+ import { custom_renderer } from '../../../state.js';
4
6
  import { mark_subtree_dynamic } from './shared/fragment.js';
5
7
 
6
8
  /**
@@ -8,6 +10,10 @@ import { mark_subtree_dynamic } from './shared/fragment.js';
8
10
  * @param {Context} context
9
11
  */
10
12
  export function OnDirective(node, context) {
13
+ if (custom_renderer) {
14
+ e.incompatible_with_custom_renderer(node, '`on:`');
15
+ }
16
+
11
17
  if (context.state.analysis.runes) {
12
18
  const parent_type = context.path.at(-1)?.type;
13
19
 
@@ -17,7 +17,7 @@ import { check_element } from './shared/a11y/index.js';
17
17
  import { validate_element } from './shared/element.js';
18
18
  import { mark_subtree_dynamic } from './shared/fragment.js';
19
19
  import { object } from '../../../utils/ast.js';
20
- import { runes } from '../../../state.js';
20
+ import { runes, custom_renderer } from '../../../state.js';
21
21
 
22
22
  /**
23
23
  * @param {AST.RegularElement} node
@@ -25,13 +25,16 @@ import { runes } from '../../../state.js';
25
25
  */
26
26
  export function RegularElement(node, context) {
27
27
  validate_element(node, context);
28
- check_element(node, context);
28
+
29
+ if (!custom_renderer) {
30
+ check_element(node, context);
31
+ }
29
32
 
30
33
  node.metadata.path = [...context.path];
31
34
  context.state.analysis.elements.push(node);
32
35
 
33
36
  // Special case: Move the children of <textarea> into a value attribute if they are dynamic
34
- if (node.name === 'textarea' && node.fragment.nodes.length > 0) {
37
+ if (!custom_renderer && node.name === 'textarea' && node.fragment.nodes.length > 0) {
35
38
  for (const attribute of node.attributes) {
36
39
  if (attribute.type === 'Attribute' && attribute.name === 'value') {
37
40
  e.textarea_invalid_content(node);
@@ -110,7 +113,10 @@ export function RegularElement(node, context) {
110
113
 
111
114
  // Special case: <select>, <option> or <optgroup> with rich content needs special hydration handling
112
115
  // We mark the subtree as dynamic so parent elements properly include the child init code
113
- if (is_customizable_select_element(node) || node.name === 'selectedcontent') {
116
+ if (
117
+ (is_customizable_select_element(node) || node.name === 'selectedcontent') &&
118
+ !custom_renderer
119
+ ) {
114
120
  // Mark the element's own fragment as dynamic so it's not treated as static
115
121
  node.fragment.metadata.dynamic = true;
116
122
  // Also mark ancestor fragments so parents properly include the child init code
@@ -157,7 +163,7 @@ export function RegularElement(node, context) {
157
163
  mark_subtree_dynamic(context.path);
158
164
  }
159
165
 
160
- if (context.state.parent_element) {
166
+ if (context.state.parent_element && !custom_renderer) {
161
167
  let past_parent = false;
162
168
  let only_warn = false;
163
169
  const ancestors = [context.state.parent_element];
@@ -218,7 +224,8 @@ export function RegularElement(node, context) {
218
224
  context.state.analysis.source[node.end - 2] === '/' &&
219
225
  !is_void(node_name) &&
220
226
  !is_svg(node_name) &&
221
- !is_mathml(node_name)
227
+ !is_mathml(node_name) &&
228
+ !custom_renderer
222
229
  ) {
223
230
  w.element_invalid_self_closing_tag(node, node.name);
224
231
  }
@@ -1,6 +1,7 @@
1
1
  /** @import { AST } from '#compiler' */
2
2
  /** @import { Context } from '../types' */
3
3
  import * as e from '../../../errors.js';
4
+ import { custom_renderer } from '../../../state.js';
4
5
  import { is_event_attribute } from '../../../utils/ast.js';
5
6
  import { disallow_children } from '../../nodes.js';
6
7
  import { check_global_event_reference } from './shared/utils.js';
@@ -10,6 +11,10 @@ import { check_global_event_reference } from './shared/utils.js';
10
11
  * @param {Context} context
11
12
  */
12
13
  export function SvelteBody(node, context) {
14
+ if (custom_renderer) {
15
+ e.incompatible_with_custom_renderer(node, '`<svelte:body>`');
16
+ }
17
+
13
18
  disallow_children(node);
14
19
  for (const attribute of node.attributes) {
15
20
  if (attribute.type === 'Attribute' && is_event_attribute(attribute)) {
@@ -2,6 +2,7 @@
2
2
  /** @import { Context } from '../types' */
3
3
  import { disallow_children } from '../../nodes.js';
4
4
  import * as e from '../../../errors.js';
5
+ import { custom_renderer } from '../../../state.js';
5
6
  import { is_event_attribute } from '../../../utils/ast.js';
6
7
  import { check_global_event_reference } from './shared/utils.js';
7
8
 
@@ -10,6 +11,10 @@ import { check_global_event_reference } from './shared/utils.js';
10
11
  * @param {Context} context
11
12
  */
12
13
  export function SvelteDocument(node, context) {
14
+ if (custom_renderer) {
15
+ e.incompatible_with_custom_renderer(node, '`<svelte:document>`');
16
+ }
17
+
13
18
  disallow_children(node);
14
19
 
15
20
  for (const attribute of node.attributes) {
@@ -5,6 +5,7 @@ import { is_text_attribute } from '../../../utils/ast.js';
5
5
  import { check_element } from './shared/a11y/index.js';
6
6
  import { validate_element } from './shared/element.js';
7
7
  import { mark_subtree_dynamic } from './shared/fragment.js';
8
+ import { custom_renderer } from '../../../state.js';
8
9
 
9
10
  /**
10
11
  * @param {AST.SvelteElement} node
@@ -12,7 +13,10 @@ import { mark_subtree_dynamic } from './shared/fragment.js';
12
13
  */
13
14
  export function SvelteElement(node, context) {
14
15
  validate_element(node, context);
15
- check_element(node, context);
16
+
17
+ if (!custom_renderer) {
18
+ check_element(node, context);
19
+ }
16
20
 
17
21
  node.metadata.path = [...context.path];
18
22
  context.state.analysis.elements.push(node);
@@ -1,6 +1,7 @@
1
1
  /** @import { AST } from '#compiler' */
2
2
  /** @import { Context } from '../types' */
3
3
  import * as e from '../../../errors.js';
4
+ import { custom_renderer } from '../../../state.js';
4
5
  import { mark_subtree_dynamic } from './shared/fragment.js';
5
6
 
6
7
  /**
@@ -8,6 +9,10 @@ import { mark_subtree_dynamic } from './shared/fragment.js';
8
9
  * @param {Context} context
9
10
  */
10
11
  export function SvelteHead(node, context) {
12
+ if (custom_renderer) {
13
+ e.incompatible_with_custom_renderer(node, '`<svelte:head>`');
14
+ }
15
+
11
16
  for (const attribute of node.attributes) {
12
17
  e.svelte_head_illegal_attribute(attribute);
13
18
  }
@@ -2,6 +2,7 @@
2
2
  /** @import { Context } from '../types' */
3
3
  import { disallow_children } from '../../nodes.js';
4
4
  import * as e from '../../../errors.js';
5
+ import { custom_renderer } from '../../../state.js';
5
6
  import { is_event_attribute } from '../../../utils/ast.js';
6
7
  import { check_global_event_reference } from './shared/utils.js';
7
8
 
@@ -10,6 +11,10 @@ import { check_global_event_reference } from './shared/utils.js';
10
11
  * @param {Context} context
11
12
  */
12
13
  export function SvelteWindow(node, context) {
14
+ if (custom_renderer) {
15
+ e.incompatible_with_custom_renderer(node, '`<svelte:window>`');
16
+ }
17
+
13
18
  disallow_children(node);
14
19
 
15
20
  for (const attribute of node.attributes) {
@@ -4,6 +4,7 @@ import { is_tag_valid_with_parent } from '../../../../html-tree-validation.js';
4
4
  import { regex_bidirectional_control_characters, regex_not_whitespace } from '../../patterns.js';
5
5
  import * as e from '../../../errors.js';
6
6
  import * as w from '../../../warnings.js';
7
+ import { custom_renderer } from '../../../state.js';
7
8
  import { extract_svelte_ignore } from '../../../utils/extract_svelte_ignore.js';
8
9
 
9
10
  /**
@@ -16,7 +17,8 @@ export function Text(node, context) {
16
17
  if (
17
18
  parent.type === 'Fragment' &&
18
19
  context.state.parent_element &&
19
- regex_not_whitespace.test(node.data)
20
+ regex_not_whitespace.test(node.data) &&
21
+ !custom_renderer
20
22
  ) {
21
23
  const message = is_tag_valid_with_parent('#text', context.state.parent_element);
22
24
  if (message) {
@@ -1,6 +1,7 @@
1
1
  /** @import { AST } from '#compiler' */
2
2
  /** @import { Context } from '../types' */
3
3
  import * as e from '../../../errors.js';
4
+ import { custom_renderer } from '../../../state.js';
4
5
 
5
6
  import { mark_subtree_dynamic } from './shared/fragment.js';
6
7
 
@@ -9,6 +10,11 @@ import { mark_subtree_dynamic } from './shared/fragment.js';
9
10
  * @param {Context} context
10
11
  */
11
12
  export function TransitionDirective(node, context) {
13
+ if (custom_renderer) {
14
+ const directive = node.intro && node.outro ? '`transition:`' : node.intro ? '`in:`' : '`out:`';
15
+ e.incompatible_with_custom_renderer(node, directive);
16
+ }
17
+
12
18
  mark_subtree_dynamic(context.path);
13
19
 
14
20
  context.next({ ...context.state, expression: node.metadata.expression });
@@ -4,6 +4,7 @@ import { get_attribute_expression, is_expression_attribute } from '../../../../u
4
4
  import { regex_illegal_attribute_character } from '../../../patterns.js';
5
5
  import * as e from '../../../../errors.js';
6
6
  import * as w from '../../../../warnings.js';
7
+ import { custom_renderer } from '../../../../state.js';
7
8
  import {
8
9
  validate_attribute,
9
10
  validate_attribute_name,
@@ -73,12 +74,12 @@ export function validate_element(node, context) {
73
74
  validate_slot_attribute(context, attribute);
74
75
  }
75
76
 
76
- if (attribute.name === 'is') {
77
+ if (attribute.name === 'is' && !custom_renderer) {
77
78
  w.attribute_avoid_is(attribute);
78
79
  }
79
80
 
80
81
  const correct_name = react_attributes.get(attribute.name);
81
- if (correct_name) {
82
+ if (correct_name && !custom_renderer) {
82
83
  w.attribute_invalid_property_name(attribute, attribute.name, correct_name);
83
84
  }
84
85