-1 is an impossible state

pull/12073/head
Rich Harris 6 months ago
parent 5b11c396f2
commit 45acc8f8fe

@ -321,19 +321,20 @@ export function execute_reaction_fn(reaction) {
* @returns {void}
*/
function remove_reaction(signal, dependency) {
const reactions = dependency.reactions;
let reactions_length = 0;
var reactions = dependency.reactions;
var reactions_length = 0;
if (reactions !== null) {
reactions_length = reactions.length - 1;
const index = reactions.indexOf(signal);
if (index !== -1) {
if (reactions_length === 0) {
dependency.reactions = null;
} else {
// Swap with last element and then remove.
reactions[index] = reactions[reactions_length];
reactions.pop();
}
if (reactions_length === 0) {
dependency.reactions = null;
} else {
// Swap with last element and then remove.
var index = reactions.indexOf(signal);
reactions[index] = reactions[reactions_length];
reactions.pop();
}
}

Loading…
Cancel
Save