"Can't get dom width or height" incorrectly fires for width/height values of 0.
See original GitHub issueVersion
4.2.1
Steps to reproduce
This warning from echarts: https://github.com/apache/incubator-echarts/blob/b6ab21159617b45c8077d998d468977cdd87d146/src/echarts.js#L1999 seems to be triggered when !dom.clientWidth
, however I believe it is valid for dom.clientWidth
to have a value of 0
.
I’m not sure why this warning was added, but I think the check should be dom.clientWidth === undefined
if the check is for a failure of the clientWidth
API to exist.
What is expected?
warning should not occur for element width/height of 0
What is actually happening?
warning is logged.
I’m happy to resolve this issue, but I’d like some confirmation my hunch is correct, or a clarification for why it is not.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:19 (2 by maintainers)
Top Results From Across the Web
[GitHub] [echarts] lougroshek commented on issue #10478
console.warn Can't get DOM width or height. Please check dom.clientWidth and dom.clientHeight. They should not be 0.
Read more >View's getWidth() and getHeight() returns 0 - Stack Overflow
I am trying to get the width and height of a button so that I can rotate that button around. I am just...
Read more >Optimize Cumulative Layout Shift - web.dev
Summary: Always include width and height size attributes on your images and video elements. Alternatively, reserve the required space with ...
Read more >viewBox - SVG: Scalable Vector Graphics - MDN Web Docs
Note: Values for width or height lower or equal to 0 disable rendering of the element. marker. For <marker> , viewBox defines the...
Read more >WebGL Resizing the Canvas.
Using JavaScript we can check what size that element is being displayed and then adjust its ... gl.viewport(0, 0, gl.canvas.width, gl.canvas.height); .
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m seeing this during jest testing and am providing parent width and height (and have also attempted to set window innerHeight and innerWidth in various ways). Just a warning, but would love if we could resolve somehow.
Have also tried other ways of setting window size before the test, both in
beforeEach()
and in the test itself:echarts 5.1.2 echarts-for-react 3.0.1 jest-dom 5.14.1
echarts-5.1.1: I was also getting this issue when a <div> containing the chart is initially set to display:none;