#3214·lottie-web

setLoop assigns any value verbatim: a string silently disables completion

Author: GamoteCreated Aug 12, 2026Updated Aug 12, 2026
javascript
AnimationItem.prototype.setLoop = function (isLooping) {
  this.loop = isLooping;
};

The setter neither coerces nor validates. The declared type says boolean, the player accepts numbers throughout, and a string arrives easily in practice (any value read from a data- attribute or an input). A string like "3" is truthy, so the animation keeps looping, but completion compares this.playCount === this.loop, and a number never strictly equals a string, so the animation loops forever with no warning.

javascript
anim.setLoop("3"); // reads as: loop three times
// plays forever: playCount === "3" is never true

Separately, setLoop does not touch playCount, so lowering the target below the current counter also never completes even with a well-typed number (details in #3213; the two interact).

Coercing in the setter (true, false, or Number(value)) and defining what happens to the pass counter on a change would close both doors.