fix: accept SVG elements in autoAnimate TypeScript types - #243
Open
cpruijsen wants to merge 1 commit into
Open
Conversation
The core already tracks parents as Element and animates SVG at runtime, but the public signature only allowed HTMLElement, which broke Svelte actions and TS callers (issue formkit#100). Widen the contract to HTMLElement | SVGElement and stop adapter instanceof HTMLElement gates from silently skipping SVG nodes.
|
@cpruijsen is attempting to deploy a commit to the Formkit Team on Vercel. A member of the Team first needs to authorize it. |
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
Widen
autoAnimate()andvAutoAnimatefromHTMLElementtoHTMLElement | SVGElement. SVG parents already animate at runtime (reporter confirmed in #100); Svelte'suse:autoAnimateand TS callers failed withSVGSVGElementnot assignable toHTMLElement. Matches Justin: "Yeah I suppose SVGElement and HTMLElement would both be valid."Update framework
instanceof HTMLElementgates so React/Vue/Preact/Solid/Qwik/Marko do not silently skip SVG now that the core type allows it. Reset exit-animation inline styles onSVGElementas well asHTMLElement.Fixes #100
Decision
HTMLElement | SVGElementon the public API, plus matching adapterinstanceofchecks. Alternatives: change only the core signature, or widen all the way toElement.Justin asked for HTML and SVG specifically;
Elementhas no.stylein TypeScript's DOM lib. Leavinginstanceof HTMLElementin the hooks would make the new types a trap (ref attaches, nothing animates).Can drop the adapter hunks and keep a core-only type change.
The comment on #100 about
offsetWidth/offsetHeightbeing removed fromSVGElementis a different line: those reads are ondocument.documentElement, not the animated parent.Test plan
tests/types/svg-element.tsfailstscwithout the signature change and passes with it (same diagnostic as the issue).HTMLElementstill type-checks.<svg use:autoAnimate>with keyed<rect>add/remove still animates (reporter already verified this before the type fix).useAutoAnimateref on an<svg>now starts animations (runtime gate change).