Repository navigation
fix(wc): apply stateMachineId and stateMachineConfig when set as properties - #1009
Open
pcbeingused333 wants to merge 2 commits into
Open
pcbeingused333 wants to merge 2 commits into
pcbeingused333 wants to merge 2 commits into
Conversation
…erties The two members were plain Lit properties, so assigning them after the player was created never reached it; only the attribute path called stateMachineLoad/Start/Stop and stateMachineSetConfig. Move that logic into setters (as themeId and renderConfig already do) and drop the duplicate attribute branches.
🦋 Changeset detectedLatest commit: 8b8883e The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
theashraf
reviewed
Nov 20, 2026
| } | ||
|
|
||
| public set stateMachineId(value: Config['stateMachineId']) { | ||
| this._stateMachineId = value; |
Member
There was a problem hiding this comment.
Thanks, tested on both elements and it works well.
One thing: the old attribute branch skipped when old === value. Now setting the same id again restarts the state machine. A guard here brings that back:
Suggested change
| this._stateMachineId = value; | |
| if (value === this._stateMachineId) return; | |
| this._stateMachineId = value; |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Setting
stateMachineIdorstateMachineConfigas a JavaScript property on<dotlottie-wc>/<dotlottie-worker-wc>after the animation has loaded has no effect: the state machine is never loaded, started, stopped or reconfigured. Only changing the attribute worked, becauseattributeChangedCallbackwas the only place that calledstateMachineLoad/stateMachineStart/stateMachineStopandstateMachineSetConfig; the properties themselves were plain Lit fields. The React and Vue wrappers already react to changes of these props.Fix: turn both into accessor properties whose setters apply the change to the player, the same way
themeIdandrenderConfigalready work, and remove the now-redundant attribute branches (attributes still reach the setter through Lit's attribute converter, so the player is called once per change).Tests: adds a property-assignment case for each member, run for both elements. They fail on
main(expected "stateMachineLoad" to be called 1 times, but got 0 times) and pass with the change; the existing attribute-based tests still pass.Package(s) affected
@lottiefiles/dotlottie-web(core)@lottiefiles/dotlottie-react@lottiefiles/dotlottie-vue@lottiefiles/dotlottie-svelte@lottiefiles/dotlottie-solid@lottiefiles/dotlottie-wcType of change
Checklist
AI assistance was used to prepare this change.