Fix SVG transform animations not applied without other SVG attributes#3632
Merged
mattgperry merged 1 commit intomainfrom Mar 12, 2026
Merged
Fix SVG transform animations not applied without other SVG attributes#3632mattgperry merged 1 commit intomainfrom
mattgperry merged 1 commit intomainfrom
Conversation
Greptile SummaryThis PR fixes a cross-browser bug where SVG elements ( Key changes:
Confidence Score: 5/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["Motion element (HTML or SVG)"] --> B["isHTMLElement(element)"]
B --> C{"isObject(element)\nAND\n'offsetHeight' in element\nAND\nNOT 'ownerSVGElement' in element"}
C -- "true (HTML element)" --> D["supportsBrowserAnimation()\n→ WAAPI path\n(hardware-accelerated)"]
C -- "false (SVG element)" --> E["JS animation path\n(motion-dom render pipeline)"]
E --> F["addStyleValue() in effects/style\nif !isHTMLElement → set transformBox: fill-box\nand transformOrigin"]
F --> G["SVG transform applied\ncorrectly via style.transform"]
D --> H["WAAPI animates element.animate()\n(bypasses SVG render pipeline)"]
style C fill:#f9f,stroke:#333
style E fill:#9f9,stroke:#333
style H fill:#f99,stroke:#333
style G fill:#9f9,stroke:#333
Last reviewed commit: a9d3af0 |
…#3081) The isHTMLElement() check used "offsetHeight" in element, which returns true for SVG elements in Chrome (where offsetHeight exists on SVGElement prototype, though deprecated). This caused supportsBrowserAnimation() to incorrectly route SVG transform animations through WAAPI instead of the JS animation path, bypassing the SVG render pipeline that sets transformBox and transformOrigin. Add an exclusion for SVG elements via "ownerSVGElement" in element. Fixes #3081 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
a9d3af0 to
86907d1
Compare
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
isHTMLElement()to exclude SVG elements, which were incorrectly identified as HTML elements in Chrome/Edge due tooffsetHeightexisting on the SVGElement prototype (deprecated but still present)supportsBrowserAnimation()to route SVGtransformanimations through WAAPI instead of the JS animation path, bypassing the SVG render pipeline that setstransformBox: fill-boxandtransformOrigintransform+stroke/fillanimation withoutx/y)Bug
In Chrome/Edge, SVG transform animations were not applied unless other SVG-specific attributes like
xorywere also animated. The root cause was theisHTMLElement()utility using"offsetHeight" in elementas a heuristic, which returnstruefor SVG elements in Chromium browsers whereoffsetHeightis still on the SVGElement prototype (though deprecated since Chrome 48). This incorrectly sent SVG transform animations through the WAAPI code path.Fix
Add
!("ownerSVGElement" in element)to theisHTMLElement()check. TheownerSVGElementproperty is present on all SVG elements (returningnullfor root<svg>, and the nearest<svg>ancestor for inner elements), making it a reliable cross-iframe way to exclude SVG elements.Test plan
isHTMLElementwith inner SVG elements (<rect>,<g>)transform+stroke/fillwithoutx/y)yarn buildpassesyarn testpasses (776 tests, 0 failures)Fixes #3081
🤖 Generated with Claude Code