Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to get width/height before calling getClientRects() #801

Closed
khesualdo opened this issue Jun 28, 2020 · 1 comment
Closed

Not able to get width/height before calling getClientRects() #801

khesualdo opened this issue Jun 28, 2020 · 1 comment

Comments

@khesualdo
Copy link

<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%">
</svg>

Specifying the width/height of svg node in % makes them inaccessible through svg.width/height.baseVal.value, even tho using % is allowed, not sure why this is so?

Wrapping svg.width/height.baseVal.value in window.onload does not change anything. Only able to access width/height when svg.getClientRects() is invoked beforehand.

// svg is the svg DOM node
svg.getClientRects(); // Must be called
const svgWidth = svg.width.baseVal.value;
const svgHeight = svg.height.baseVal.value;

P.S. (In Chrome)

console.log(svg.width.baseVal); // Preview shows 0, when expanded shows the actual width
console.log(svg.height.baseVal.value); // Shows 0
@fsoder
Copy link

fsoder commented Jun 28, 2020

This is a browser bug, please report it at https://crbug.com/new - the bug-tracker for Chrome - since you mentioned it. If you see this bug elsewhere then please report it to them as well. Then close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants