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

SVG <rect> changes size in Chrome #2

Open
tlrobinson opened this issue Apr 5, 2017 · 1 comment
Open

SVG <rect> changes size in Chrome #2

tlrobinson opened this issue Apr 5, 2017 · 1 comment

Comments

@tlrobinson
Copy link

If you have an SVG element with width and height attributes (not style) it seems Chrome reports the computed width and height as auto, which overrides the attributes when using computed-style-to-inline-style

Demo: https://jsfiddle.net/uqL9hxnk/1/

This doesn't happen in Safari or Firefox, so maybe it's a bug in Chrome. It would be nice if computed-style-to-inline-style worked around it though.

@tlrobinson
Copy link
Author

The following workaround works in my case:

for (const attribute of ["width", "height"]) {
    for (const rect of element.querySelectorAll(`svg [${attribute}]`)) {
        rect.style[attribute] = "";
    }
}

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

1 participant