Skip to content

Commit 77b1f2f

Browse files
authored
chore: remove more .at() usage from runtime (#10648)
1 parent 749d3aa commit 77b1f2f

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

packages/svelte/src/internal/client/dev/ownership.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ export function mark_module_end() {
7575
const end = get_stack()?.[2];
7676

7777
if (end) {
78-
// @ts-expect-error
79-
boundaries[end.file].at(-1).end = end;
78+
const boundaries_file = boundaries[end.file];
79+
boundaries_file[boundaries_file.length - 1].end = end;
8080
}
8181
}
8282

packages/svelte/src/internal/client/dom/blocks/each.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,8 @@ function reconcile_indexed_array(
393393
b_blocks[index] = block;
394394

395395
hydrating_node = /** @type {import('../../types.js').TemplateNode} */ (
396-
/** @type {Node} */ (/** @type {Node} */ (fragment.at(-1)).nextSibling).nextSibling
396+
/** @type {Node} */ (/** @type {Node} */ (fragment[fragment.length - 1]).nextSibling)
397+
.nextSibling
397398
);
398399
}
399400

@@ -517,7 +518,8 @@ function reconcile_tracked_array(
517518
// Get the <!--ssr:..--> tag of the next item in the list
518519
// The fragment array can be empty if each block has no content
519520
hydrating_node = /** @type {import('../../types.js').TemplateNode} */ (
520-
/** @type {Node} */ ((fragment.at(-1) || hydrating_node).nextSibling).nextSibling
521+
/** @type {Node} */ ((fragment[fragment.length - 1] || hydrating_node).nextSibling)
522+
.nextSibling
521523
);
522524
}
523525

packages/svelte/src/internal/client/operations.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,10 +274,10 @@ function capture_fragment_from_node(node) {
274274
if (
275275
node.nodeType === 8 &&
276276
/** @type {Comment} */ (node).data.startsWith('ssr:') &&
277-
current_hydration_fragment.at(-1) !== node
277+
current_hydration_fragment[current_hydration_fragment.length - 1] !== node
278278
) {
279279
const fragment = /** @type {Array<Element | Text | Comment>} */ (get_hydration_fragment(node));
280-
const last_child = fragment.at(-1) || node;
280+
const last_child = fragment[fragment.length - 1] || node;
281281
const target = /** @type {Node} */ (last_child.nextSibling);
282282
// @ts-ignore
283283
target.$$fragment = fragment;

0 commit comments

Comments
 (0)