fix(web): remove animated attributes when value is undefined#2439
Merged
Conversation
`applyAnimatedValues` previously called `setAttribute(name, undefined)`, which coerces to the string "undefined". For boolean-style attributes like `inert` or `disabled`, the attribute's presence is what matters — "undefined" keeps them active. The attribute must be removed entirely. Now: when an animated value resolves to `undefined`, the attribute is removed via `removeAttribute`. The same applies to `viewBox`, `className`, and `children` (which clears `textContent`). Defined falsy values such as `0` or `""` continue to flow through `setAttribute`. Co-authored-by: LoganDark <github@logandark.mozmail.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: e65c1bd The changes in this PR will be included in the next version bump. This PR includes changesets to release 12 packages
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 |
This was referenced May 21, 2026
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.
Summary
Animated DOM attributes whose value resolves to
undefinedare now removed viaremoveAttributeinstead of coerced to the string"undefined". Boolean-style attributes likeinertanddisabledwere broken because their presence enables them — any value (including"undefined") keeps them active. The same fix applies toviewBox,className, andchildren(which now clearstextContent).Defined falsy values such as
0or""are unaffected and still go throughsetAttribute.Tests
Six new cases in
targets/web/src/animated.test.tsxunderanimated component attribute removal:inertremoved when its animated value becomesundefineddata-foo) removed when value becomesundefinedviewBoxremoved when value becomesundefinedclassNameremoved when value becomesundefinedchildrenclearstextContentwhen value becomesundefinedtabIndex={'0'}) still applied viasetAttributeTests use a small
TestFluid<T>helper that extendsFluidValueso a value can transition toundefined(whichSpringValueitself does not support).Notes
Closes #2319 by @LoganDark, rebased onto
nextand extended to handleclassName(per reviewer comment on the original PR). Original author credited viaCo-authored-byon the commit.