Comments (7)
After upgrading to version 2.x, my tests started failing with this error message.
It's caused by this piece of code:
/**
* Update the SVG dimensions and path length
*/
SVGVisualElement.prototype.measure = function () {
try {
this.dimensions =
typeof this.element.getBBox ===
"function"
? this.element.getBBox()
: this.element.getBoundingClientRect();
}
catch (e) {
// Most likely trying to measure an unrendered element under Firefox
this.dimensions = { x: 0, y: 0, width: 0, height: 0 };
}
if (isPath(this.element)) {
this.totalPathLength = this.element.getTotalLength();
}
};
With this.element.getTotalLength();
throwing the error, since getTotalLength
doesn't exist on the SVGElement
.
What changed, since it was working in version 1.x?
For now I've solved it by adding the following to my test setup file, to make sure it's defined:
if (!SVGElement.prototype.getTotalLength) {
SVGElement.prototype.getTotalLength = () => 1;
}
from motion.
This is a bug in JSDom: jsdom/jsdom#1330
I'm going to leave this ticket open as we can probably duck-type this in https://github.com/Popmotion/popmotion/tree/master/packages/stylefire so it at the very least doesn't break tests.
from motion.
π π
from motion.
if (!SVGElement.prototype.getTotalLength) { SVGElement.prototype.getTotalLength = () => 1; }
Yep, experiencing the same problem after upgrading framer-motion
from v1.10.3
to v2.3.0
. This happens only when using JSDOM (with Enzyme) while under test. Everything works as expected in a standard browser environment.
Thanks for the snippet, that helped me to work around the problem for the time being.
from motion.
Any update on this issue, except including the above snippet code?
from motion.
Also experience this issue, this error occurred in a component: Error: Uncaught [TypeError: this.element.getTotalLength is not a function]
version: 3.2.2-rc.1
from motion.
Isn't there a proper polyfill for extending SVG base classes like SVGGeometryElement etc to include in test environments?
from motion.
Related Issues (20)
- [FEATURE] Expose moved item index in Reorder.group
- ref prop does not work on div directly inside AnimatePresence with mode="popLayout" [BUG] HOT 1
- how to jump to specific position in animation sequenceοΌ
- [BUG] ScaleZ doesn't get applied to the motion component
- [BUG] problems with useMotionValue and useSpring to make an object follow the cursor after v11.
- [BUG] RotateZ not working in Shared Layout Animation HOT 2
- [BUG] v11 breaks all animations using vh and dvh as css unit HOT 1
- [BUG] v11 regression when cloning `motion` components HOT 2
- [BUG] Blinking on Enter and Exit Animations with layoutId and AnimatePresence
- [BUG] AnimatePresence - enter and exit animations are mixed when they alternate rapidly HOT 5
- [BUG] When resizing a canvas with a LayoutCamera, pointer events on meshes are aligned incorrectly.
- [BUG] Elements do not animate in latest React 19 canaries HOT 6
- [BUG] ReferenceError: React is not defined Just by importing framer-motion HOT 3
- [BUG] Docs: Application error: a client-side exception has occurred (see the browser console for more information). HOT 1
- [BUG] Property '$$typeof' is missing in `ForwardRefComponent` HOT 2
- [BUG] Next.js render error when first loaded
- [BUG] whileInView transition values override the other transition values
- [BUG] Components wrapped in `motion` don't pass props starting with "drag"
- [BUG] AnimatePresence skips 3D Elements
- [BUG] react@beta (19) breaks motion's type HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from motion.