Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/real-dolphins-return.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: use cached indexOf array prototype method internally
4 changes: 2 additions & 2 deletions packages/svelte/src/internal/client/runtime.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @import { ComponentContext, Derived, Effect, Reaction, Signal, Source, Value } from '#client' */
import { DEV } from 'esm-env';
import { define_property, get_descriptors, get_prototype_of } from '../shared/utils.js';
import { define_property, get_descriptors, get_prototype_of, index_of } from '../shared/utils.js';
import {
destroy_block_effect_children,
destroy_effect_children,
Expand Down Expand Up @@ -448,7 +448,7 @@ export function update_reaction(reaction) {
function remove_reaction(signal, dependency) {
let reactions = dependency.reactions;
if (reactions !== null) {
var index = reactions.indexOf(signal);
var index = index_of.call(reactions, signal);
if (index !== -1) {
var new_length = reactions.length - 1;
if (new_length === 0) {
Expand Down
1 change: 1 addition & 0 deletions packages/svelte/src/internal/shared/utils.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Store the references to globals in case someone tries to monkey patch these, causing the below
// to de-opt (this occurs often when using popular extensions).
export var is_array = Array.isArray;
export var index_of = Array.prototype.indexOf;
export var array_from = Array.from;
export var object_keys = Object.keys;
export var define_property = Object.defineProperty;
Expand Down
Loading