airbnb / lottie-web

Render After Effects animations natively on Web, Android and iOS, and React Native. http://airbnb.io/lottie/
MIT License
29.85k stars 2.85k forks source link

Don't re-add existing styles to SVGShapeElement #3039

Closed geomaster closed 3 months ago

geomaster commented 8 months ago

This is a recreation of PR #2983, since that one erroneously used our fork's master, which has since gotten additional commits. See that PR for previous discussion.

When calling SVGShapeElement.reloadShapes(), searchShapes() will correctly reconcile modified and added shapes and reuse their elements. However, it will call setElementStyles(), which will add all style elements unconditionally to this.stylesList, even if the styles were already in there, making it grow indefinitely and causing other problems down the line.

Modify setElementStyles() to check for the existence of a particular style before adding it.