svelte 5.57.0 → 5.57.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/compiler/index.js +1 -1
- package/package.json +8 -8
- package/src/compiler/errors.js +10 -0
- package/src/compiler/migrate/index.js +15 -4
- package/src/compiler/phases/1-parse/acorn.js +36 -2
- package/src/compiler/phases/1-parse/index.js +23 -22
- package/src/compiler/phases/1-parse/read/context.js +3 -18
- package/src/compiler/phases/1-parse/read/expression.js +110 -2
- package/src/compiler/phases/1-parse/read/script.js +1 -1
- package/src/compiler/phases/1-parse/read/style.js +3 -5
- package/src/compiler/phases/1-parse/state/element.js +68 -40
- package/src/compiler/phases/1-parse/state/tag.js +8 -6
- package/src/compiler/phases/1-parse/utils/html.js +2 -0
- package/src/compiler/phases/1-parse/utils/whitespace.js +18 -0
- package/src/compiler/phases/2-analyze/css/css-prune.js +7 -6
- package/src/compiler/phases/2-analyze/index.js +1 -1
- package/src/compiler/phases/2-analyze/visitors/BindDirective.js +1 -1
- package/src/compiler/phases/2-analyze/visitors/ClassDeclaration.js +1 -1
- package/src/compiler/phases/2-analyze/visitors/FunctionDeclaration.js +1 -1
- package/src/compiler/phases/2-analyze/visitors/Identifier.js +1 -2
- package/src/compiler/phases/2-analyze/visitors/LetDirective.js +22 -0
- package/src/compiler/phases/2-analyze/visitors/SvelteBody.js +1 -1
- package/src/compiler/phases/2-analyze/visitors/SvelteDocument.js +1 -1
- package/src/compiler/phases/2-analyze/visitors/SvelteWindow.js +1 -1
- package/src/compiler/phases/2-analyze/visitors/VariableDeclarator.js +2 -2
- package/src/compiler/phases/2-analyze/visitors/shared/a11y/constants.js +1 -1
- package/src/compiler/phases/2-analyze/visitors/shared/a11y/index.js +3 -3
- package/src/compiler/phases/2-analyze/visitors/shared/utils.js +0 -38
- package/src/compiler/phases/3-transform/client/utils.js +0 -38
- package/src/compiler/phases/3-transform/client/visitors/AssignmentExpression.js +2 -2
- package/src/compiler/phases/3-transform/client/visitors/AwaitExpression.js +2 -1
- package/src/compiler/phases/3-transform/client/visitors/CallExpression.js +1 -2
- package/src/compiler/phases/3-transform/client/visitors/VariableDeclaration.js +3 -8
- package/src/compiler/phases/3-transform/client/visitors/shared/events.js +3 -2
- package/src/compiler/phases/3-transform/server/visitors/shared/element.js +8 -0
- package/src/compiler/phases/3-transform/utils.js +1 -1
- package/src/compiler/phases/nodes.js +30 -0
- package/src/compiler/phases/scope.js +85 -2
- package/src/compiler/print/index.js +3 -1
- package/src/compiler/state.js +9 -5
- package/src/compiler/utils/ast.js +2 -5
- package/src/compiler/utils/compile_diagnostic.js +1 -1
- package/src/compiler/utils/extract_svelte_ignore.js +1 -1
- package/src/compiler/utils/mapped_code.js +13 -1
- package/src/index-client.js +1 -1
- package/src/internal/client/constants.js +0 -9
- package/src/internal/client/dev/debug.js +0 -2
- package/src/internal/client/dev/tracing.js +3 -1
- package/src/internal/client/dom/blocks/boundary.js +39 -8
- package/src/internal/client/dom/blocks/each.js +8 -6
- package/src/internal/client/dom/blocks/svelte-element.js +3 -1
- package/src/internal/client/dom/css.js +1 -1
- package/src/internal/client/dom/elements/attributes.js +168 -148
- package/src/internal/client/dom/elements/bindings/document.js +3 -2
- package/src/internal/client/dom/elements/events.js +6 -1
- package/src/internal/client/dom/elements/transitions.js +3 -3
- package/src/internal/client/error-handling.js +5 -1
- package/src/internal/client/errors.js +0 -16
- package/src/internal/client/proxy.js +12 -7
- package/src/internal/client/reactivity/async.js +5 -0
- package/src/internal/client/reactivity/batch.js +103 -75
- package/src/internal/client/reactivity/deriveds.js +0 -3
- package/src/internal/client/reactivity/sources.js +31 -19
- package/src/internal/client/reactivity/utils.js +2 -23
- package/src/internal/client/runtime.js +18 -25
- package/src/internal/server/context.js +9 -2
- package/src/internal/server/index.js +9 -2
- package/src/internal/server/renderer.js +101 -69
- package/src/internal/shared/errors.js +16 -0
- package/src/reactivity/date.js +2 -2
- package/src/reactivity/url-search-params.js +1 -1
- package/src/version.js +1 -1
- package/types/index.d.ts.map +1 -1
- package/src/compiler/phases/1-parse/utils/create.js +0 -16
- package/src/compiler/phases/2-analyze/visitors/shared/special-element.js +0 -16
- package/src/compiler/utils/push_array.js +0 -13
- /package/src/compiler/{phases/2-analyze/utils → utils}/check_graph_for_cycles.js +0 -0
- /package/src/compiler/{phases/1-parse/utils → utils}/fuzzymatch.js +0 -0
package/src/compiler/state.js
CHANGED
|
@@ -33,10 +33,14 @@ export let component_name = '<unknown>';
|
|
|
33
33
|
export let source;
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
|
-
* The source code split into lines
|
|
37
|
-
* @type {string[]}
|
|
36
|
+
* The source code split into lines, initialized when a diagnostic needs a code frame
|
|
37
|
+
* @type {string[] | undefined}
|
|
38
38
|
*/
|
|
39
|
-
|
|
39
|
+
let source_lines;
|
|
40
|
+
|
|
41
|
+
export function get_source_lines() {
|
|
42
|
+
return (source_lines ??= source.split('\n'));
|
|
43
|
+
}
|
|
40
44
|
|
|
41
45
|
/**
|
|
42
46
|
* True if compiling with `dev: true`
|
|
@@ -52,7 +56,7 @@ export let locator;
|
|
|
52
56
|
/** @param {string} value */
|
|
53
57
|
export function set_source(value) {
|
|
54
58
|
source = value;
|
|
55
|
-
source_lines =
|
|
59
|
+
source_lines = undefined;
|
|
56
60
|
|
|
57
61
|
const l = getLocator(source, { offsetLine: 1 });
|
|
58
62
|
|
|
@@ -141,7 +145,7 @@ export function reset(state) {
|
|
|
141
145
|
runes = false;
|
|
142
146
|
component_name = UNKNOWN_FILENAME;
|
|
143
147
|
source = '';
|
|
144
|
-
source_lines =
|
|
148
|
+
source_lines = undefined;
|
|
145
149
|
filename = (state.filename ?? UNKNOWN_FILENAME).replace(/\\/g, '/');
|
|
146
150
|
warning_filter = state.warning ?? (() => true);
|
|
147
151
|
warnings = [];
|
|
@@ -286,7 +286,7 @@ function _extract_paths(paths, inserts, param, expression, update_expression, ha
|
|
|
286
286
|
const props = [];
|
|
287
287
|
|
|
288
288
|
for (const p of param.properties) {
|
|
289
|
-
if (p.type === 'Property'
|
|
289
|
+
if (p.type === 'Property') {
|
|
290
290
|
if (p.key.type === 'Identifier' && !p.computed) {
|
|
291
291
|
props.push(b.literal(p.key.name));
|
|
292
292
|
} else if (p.key.type === 'Literal') {
|
|
@@ -548,10 +548,7 @@ export function is_expression_async(expression) {
|
|
|
548
548
|
if (property.type === 'SpreadElement') {
|
|
549
549
|
return is_expression_async(property.argument);
|
|
550
550
|
} else if (property.type === 'Property') {
|
|
551
|
-
return (
|
|
552
|
-
(property.key.type !== 'PrivateIdentifier' && is_expression_async(property.key)) ||
|
|
553
|
-
is_expression_async(property.value)
|
|
554
|
-
);
|
|
551
|
+
return is_expression_async(property.key) || is_expression_async(property.value);
|
|
555
552
|
}
|
|
556
553
|
});
|
|
557
554
|
}
|
|
@@ -15,7 +15,7 @@ function tabs_to_spaces(str) {
|
|
|
15
15
|
* @param {number} column
|
|
16
16
|
*/
|
|
17
17
|
function get_code_frame(line, column) {
|
|
18
|
-
const lines = state.
|
|
18
|
+
const lines = state.get_source_lines();
|
|
19
19
|
const frame_start = Math.max(0, line - 2);
|
|
20
20
|
const frame_end = Math.min(line + 3, lines.length);
|
|
21
21
|
const digits = String(frame_end + 1).length;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/** @import { ValidatedCompileOptions } from '#compiler' */
|
|
2
|
+
|
|
2
3
|
/** @import { Processed } from '../preprocess/public.js' */
|
|
3
4
|
/** @import { SourceMap } from 'magic-string' */
|
|
4
5
|
/** @import { Source } from '../preprocess/private.js' */
|
|
5
6
|
/** @import { DecodedSourceMap, SourceMapSegment, RawSourceMap } from '@jridgewell/remapping' */
|
|
6
7
|
import remapping from '@jridgewell/remapping';
|
|
7
|
-
import { push_array } from './push_array.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* @param {string} s
|
|
@@ -12,6 +12,18 @@ import { push_array } from './push_array.js';
|
|
|
12
12
|
function last_line_length(s) {
|
|
13
13
|
return s.length - s.lastIndexOf('\n') - 1;
|
|
14
14
|
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* `array.push(...items)` overflows the stack for large `items`.
|
|
18
|
+
* @template T
|
|
19
|
+
* @param {T[]} array
|
|
20
|
+
* @param {T[]} items
|
|
21
|
+
*/
|
|
22
|
+
function push_array(array, items) {
|
|
23
|
+
for (let i = 0; i < items.length; i++) {
|
|
24
|
+
array.push(items[i]);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
15
27
|
// mutate map in-place
|
|
16
28
|
|
|
17
29
|
/**
|
package/src/index-client.js
CHANGED
|
@@ -17,7 +17,7 @@ if (DEV) {
|
|
|
17
17
|
if (!(rune in globalThis)) {
|
|
18
18
|
// TODO if people start adjusting the "this can contain runes" config through v-p-s more, adjust this message
|
|
19
19
|
/** @type {any} */
|
|
20
|
-
let value; // let's hope
|
|
20
|
+
let value; // let's hope no one modifies this global, but belts and braces
|
|
21
21
|
Object.defineProperty(globalThis, rune, {
|
|
22
22
|
configurable: true,
|
|
23
23
|
// eslint-disable-next-line getter-return
|
|
@@ -51,15 +51,6 @@ export const EFFECT_PRESERVED = 1 << 19;
|
|
|
51
51
|
export const USER_EFFECT = 1 << 20;
|
|
52
52
|
export const EFFECT_OFFSCREEN = 1 << 25;
|
|
53
53
|
|
|
54
|
-
// Flags exclusive to deriveds
|
|
55
|
-
/**
|
|
56
|
-
* Tells that we marked this derived and its reactions as visited during the "mark as (maybe) dirty"-phase.
|
|
57
|
-
* Will be lifted during execution of the derived and during checking its dirty state (both are necessary
|
|
58
|
-
* because a derived might be checked but not executed). This is a pure performance optimization flag and
|
|
59
|
-
* should not be used for any other purpose!
|
|
60
|
-
*/
|
|
61
|
-
export const WAS_MARKED = 1 << 16;
|
|
62
|
-
|
|
63
54
|
// Flags used for async
|
|
64
55
|
export const REACTION_IS_UPDATING = 1 << 21;
|
|
65
56
|
export const ASYNC = 1 << 22;
|
|
@@ -15,7 +15,6 @@ import {
|
|
|
15
15
|
MAYBE_DIRTY,
|
|
16
16
|
RENDER_EFFECT,
|
|
17
17
|
ROOT_EFFECT,
|
|
18
|
-
WAS_MARKED,
|
|
19
18
|
MANAGED_EFFECT
|
|
20
19
|
} from '#client/constants';
|
|
21
20
|
import { snapshot } from '../../shared/clone.js';
|
|
@@ -204,7 +203,6 @@ export function log_reactions(signal) {
|
|
|
204
203
|
if ((flags & DIRTY) !== 0) names.push('DIRTY');
|
|
205
204
|
if ((flags & MAYBE_DIRTY) !== 0) names.push('MAYBE_DIRTY');
|
|
206
205
|
if ((flags & CONNECTED) !== 0) names.push('CONNECTED');
|
|
207
|
-
if ((flags & WAS_MARKED) !== 0) names.push('WAS_MARKED');
|
|
208
206
|
if ((flags & INERT) !== 0) names.push('INERT');
|
|
209
207
|
if ((flags & DESTROYED) !== 0) names.push('DESTROYED');
|
|
210
208
|
|
|
@@ -131,8 +131,10 @@ export function trace(label, fn) {
|
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
/**
|
|
134
|
-
* @
|
|
134
|
+
* @template {Value} T
|
|
135
|
+
* @param {T} source
|
|
135
136
|
* @param {string} label
|
|
137
|
+
* @returns {T}
|
|
136
138
|
*/
|
|
137
139
|
export function tag(source, label) {
|
|
138
140
|
source.label = label;
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
/** @import { Effect, Source, TemplateNode, } from '#client' */
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import {
|
|
3
|
+
BOUNDARY_EFFECT,
|
|
4
|
+
DESTROYED,
|
|
5
|
+
DESTROYING,
|
|
6
|
+
EFFECT_PRESERVED,
|
|
7
|
+
EFFECT_TRANSPARENT
|
|
8
|
+
} from '#client/constants';
|
|
9
|
+
import {
|
|
10
|
+
HYDRATION_ERROR,
|
|
11
|
+
HYDRATION_START_ELSE,
|
|
12
|
+
HYDRATION_START_FAILED
|
|
13
|
+
} from '../../../../constants.js';
|
|
4
14
|
import { component_context, set_component_context } from '../../context.js';
|
|
5
15
|
import { invoke_error_boundary } from '../../error-handling.js';
|
|
6
16
|
import {
|
|
@@ -22,6 +32,7 @@ import {
|
|
|
22
32
|
hydrate_node,
|
|
23
33
|
hydrating,
|
|
24
34
|
next,
|
|
35
|
+
read_hydration_instruction,
|
|
25
36
|
skip_nodes,
|
|
26
37
|
set_hydrate_node
|
|
27
38
|
} from '../hydration.js';
|
|
@@ -154,16 +165,18 @@ export class Boundary {
|
|
|
154
165
|
|
|
155
166
|
this.#effect = block(() => {
|
|
156
167
|
if (hydrating) {
|
|
157
|
-
const
|
|
168
|
+
const comment_data = read_hydration_instruction(
|
|
169
|
+
/** @type {TemplateNode} */ (this.#hydrate_open)
|
|
170
|
+
);
|
|
158
171
|
hydrate_next();
|
|
159
172
|
|
|
160
|
-
const server_rendered_pending =
|
|
161
|
-
const server_rendered_failed =
|
|
173
|
+
const server_rendered_pending = comment_data === HYDRATION_START_ELSE;
|
|
174
|
+
const server_rendered_failed = comment_data.startsWith(HYDRATION_START_FAILED);
|
|
162
175
|
|
|
163
176
|
if (server_rendered_failed) {
|
|
164
177
|
// Server rendered the failed snippet - hydrate it.
|
|
165
178
|
// The serialized error is embedded in the comment: <!--[?<json>-->
|
|
166
|
-
const serialized_error = JSON.parse(
|
|
179
|
+
const serialized_error = JSON.parse(comment_data.slice(HYDRATION_START_FAILED.length));
|
|
167
180
|
this.#hydrate_failed_content(serialized_error);
|
|
168
181
|
} else if (server_rendered_pending) {
|
|
169
182
|
this.#hydrate_pending_content();
|
|
@@ -220,6 +233,8 @@ export class Boundary {
|
|
|
220
233
|
var calling_on_error = false;
|
|
221
234
|
|
|
222
235
|
const reset = () => {
|
|
236
|
+
if (this.#is_destroyed()) return;
|
|
237
|
+
|
|
223
238
|
if (did_reset) {
|
|
224
239
|
w.svelte_boundary_reset_noop();
|
|
225
240
|
return;
|
|
@@ -243,6 +258,8 @@ export class Boundary {
|
|
|
243
258
|
};
|
|
244
259
|
|
|
245
260
|
const invoke_onerror = () => {
|
|
261
|
+
if (this.#is_destroyed()) return;
|
|
262
|
+
|
|
246
263
|
try {
|
|
247
264
|
calling_on_error = true;
|
|
248
265
|
this.#props.onerror?.(error, reset);
|
|
@@ -255,6 +272,10 @@ export class Boundary {
|
|
|
255
272
|
return { reset, invoke_onerror };
|
|
256
273
|
}
|
|
257
274
|
|
|
275
|
+
#is_destroyed() {
|
|
276
|
+
return (this.#effect.f & (DESTROYED | DESTROYING)) !== 0;
|
|
277
|
+
}
|
|
278
|
+
|
|
258
279
|
#hydrate_pending_content() {
|
|
259
280
|
const pending = this.#props.pending;
|
|
260
281
|
if (!pending) return;
|
|
@@ -263,6 +284,8 @@ export class Boundary {
|
|
|
263
284
|
this.#pending_effect = branch(() => pending(this.#anchor));
|
|
264
285
|
|
|
265
286
|
queue_micro_task(() => {
|
|
287
|
+
if (this.#is_destroyed()) return;
|
|
288
|
+
|
|
266
289
|
var fragment = (this.#offscreen_fragment = document.createDocumentFragment());
|
|
267
290
|
var anchor = create_text();
|
|
268
291
|
var handled = false;
|
|
@@ -445,6 +468,10 @@ export class Boundary {
|
|
|
445
468
|
|
|
446
469
|
/** @param {unknown} error */
|
|
447
470
|
error(error) {
|
|
471
|
+
if (error === HYDRATION_ERROR) {
|
|
472
|
+
throw error;
|
|
473
|
+
}
|
|
474
|
+
|
|
448
475
|
// If we have nothing to capture the error, or if we hit an error while
|
|
449
476
|
// rendering the fallback, re-throw for another boundary to handle
|
|
450
477
|
if (!this.#props.onerror && !this.#props.failed) {
|
|
@@ -457,7 +484,7 @@ export class Boundary {
|
|
|
457
484
|
if (this.#failed_effect) current_batch.skip_effect(this.#failed_effect);
|
|
458
485
|
|
|
459
486
|
current_batch.oncommit(() => {
|
|
460
|
-
this.#handle_error(error);
|
|
487
|
+
if (!this.#is_destroyed()) this.#handle_error(error);
|
|
461
488
|
});
|
|
462
489
|
} else {
|
|
463
490
|
this.#handle_error(error);
|
|
@@ -493,11 +520,13 @@ export class Boundary {
|
|
|
493
520
|
|
|
494
521
|
/** @param {unknown} transformed_error */
|
|
495
522
|
const handle_error_result = (transformed_error) => {
|
|
523
|
+
if (this.#is_destroyed()) return;
|
|
524
|
+
|
|
496
525
|
const { reset, invoke_onerror } = this.#create_reset(transformed_error);
|
|
497
526
|
|
|
498
527
|
invoke_onerror();
|
|
499
528
|
|
|
500
|
-
if (failed) {
|
|
529
|
+
if (failed && !this.#is_destroyed()) {
|
|
501
530
|
this.#failed_effect = this.#run(() => {
|
|
502
531
|
try {
|
|
503
532
|
return branch(() => {
|
|
@@ -523,6 +552,8 @@ export class Boundary {
|
|
|
523
552
|
};
|
|
524
553
|
|
|
525
554
|
queue_micro_task(() => {
|
|
555
|
+
if (this.#is_destroyed()) return;
|
|
556
|
+
|
|
526
557
|
// Run the error through the API-level transformError transform (e.g. SvelteKit's handleError)
|
|
527
558
|
/** @type {unknown} */
|
|
528
559
|
var result;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @import { EachItem, EachOutroGroup, EachState, Effect, EffectNodes, MaybeSource,
|
|
1
|
+
/** @import { EachItem, EachOutroGroup, EachState, Effect, EffectNodes, MaybeSource, TemplateNode, TransitionManager } from '#client' */
|
|
2
2
|
/** @import { Batch } from '../../reactivity/batch.js'; */
|
|
3
3
|
import {
|
|
4
4
|
EACH_INDEX_REACTIVE,
|
|
@@ -216,9 +216,6 @@ export function each(node, flags, get_collection, get_key, render_fn, fallback_f
|
|
|
216
216
|
tag(each_array, '{#each ...}');
|
|
217
217
|
}
|
|
218
218
|
|
|
219
|
-
/** @type {V[]} */
|
|
220
|
-
var array;
|
|
221
|
-
|
|
222
219
|
/** @type {Map<Batch, Set<any>>} */
|
|
223
220
|
var pending = new Map();
|
|
224
221
|
|
|
@@ -234,6 +231,11 @@ export function each(node, flags, get_collection, get_key, render_fn, fallback_f
|
|
|
234
231
|
|
|
235
232
|
state.pending.delete(batch);
|
|
236
233
|
|
|
234
|
+
// The effect doesn't necessarily re-run in a batch right before that batch commits
|
|
235
|
+
// (its view of the collection may not have changed), so we read the collection
|
|
236
|
+
// as the committing batch sees it rather than using the most recent block run's result
|
|
237
|
+
var array = get(each_array);
|
|
238
|
+
|
|
237
239
|
state.fallback = fallback;
|
|
238
240
|
reconcile(state, array, anchor, flags, get_key);
|
|
239
241
|
|
|
@@ -264,7 +266,7 @@ export function each(node, flags, get_collection, get_key, render_fn, fallback_f
|
|
|
264
266
|
}
|
|
265
267
|
|
|
266
268
|
var effect = block(() => {
|
|
267
|
-
array = /** @type {V[]} */ (get(each_array));
|
|
269
|
+
var array = /** @type {V[]} */ (get(each_array));
|
|
268
270
|
var length = array.length;
|
|
269
271
|
|
|
270
272
|
/** `true` if there was a hydration mismatch. Needs to be a `let` or else it isn't treeshaken out */
|
|
@@ -664,7 +666,7 @@ function reconcile(state, array, anchor, flags, get_key) {
|
|
|
664
666
|
* @param {V} value
|
|
665
667
|
* @param {unknown} key
|
|
666
668
|
* @param {number} index
|
|
667
|
-
* @param {(anchor: Node, item:
|
|
669
|
+
* @param {(anchor: Node, item: MaybeSource<V>, index: MaybeSource<number>, collection: () => V[]) => void} render_fn
|
|
668
670
|
* @param {number} flags
|
|
669
671
|
* @param {() => V[]} get_collection
|
|
670
672
|
* @returns {EachItem}
|
|
@@ -71,6 +71,7 @@ export function element(node, get_tag, is_svg, render_fn, get_namespace, locatio
|
|
|
71
71
|
|
|
72
72
|
branches.ensure(next_tag, (anchor) => {
|
|
73
73
|
if (next_tag) {
|
|
74
|
+
var is_hydrating = hydrating;
|
|
74
75
|
element = hydrating ? /** @type {Element} */ (element) : create_element(next_tag, ns);
|
|
75
76
|
|
|
76
77
|
if (DEV && location) {
|
|
@@ -123,7 +124,8 @@ export function element(node, get_tag, is_svg, render_fn, get_namespace, locatio
|
|
|
123
124
|
// we do this after calling `render_fn` so that child effects don't override `nodes.end`
|
|
124
125
|
/** @type {Effect & { nodes: EffectNodes }} */ (active_effect).nodes.end = element;
|
|
125
126
|
|
|
126
|
-
|
|
127
|
+
// we only move the node if we are not hydrating since a claimed element is already in place
|
|
128
|
+
if (!is_hydrating) anchor.before(element);
|
|
127
129
|
}
|
|
128
130
|
|
|
129
131
|
if (hydrating) {
|
|
@@ -12,7 +12,7 @@ export function append_styles(anchor, css) {
|
|
|
12
12
|
// Use an effect to ensure `anchor` is in the DOM, otherwise getRootNode() will yield wrong results
|
|
13
13
|
effect(() => {
|
|
14
14
|
// Bit of a hack: branches.js/each.js use offscreen fragments with temporary text nodes that will
|
|
15
|
-
// never be connected to the real dom.
|
|
15
|
+
// never be connected to the real dom. Therefore walk up to the branch that has created the component
|
|
16
16
|
// whose styles we want to append, and check its node instead. It will be connected by the time we get here.
|
|
17
17
|
anchor = active_effect?.parent?.nodes?.start ?? anchor;
|
|
18
18
|
var root = anchor.getRootNode();
|