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

Percentage units in nested <svg> is not resolved relative to the inner <svg> before emitting into the output SVG #104

Open
festim-prebreza opened this issue Mar 12, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@festim-prebreza
Copy link

festim-prebreza commented Mar 12, 2021

In cases such as this:
<div>
<svg class="small">
<circle cx="50%" cy="50%" r="50%" class="svg-circle"/>
</svg>
</div>
the circle does not calculate its width relative to its parent class "small", but relative to window I think

@felixfbecker
Copy link
Owner

Yeah, this is because <svg>s are inlined. There would need to be logic added here to handle various elements and their horizontal and vertical attributes and resolve them relative to the viewPort, similar to how it's already done for percentages in presentation attributes (which are resolved relative to the diagonal of the viewBox).

dom-to-svg/src/svg.ts

Lines 128 to 134 in a9309e4

if (isSVGGraphicsElement(element)) {
copyGraphicalPresentationAttributes(styles, elementToAppend, svgViewportElement.viewBox.animVal)
if (isSVGTextContentElement(element)) {
copyTextStyles(styles, elementToAppend)
}
}

@felixfbecker felixfbecker added the bug Something isn't working label Apr 17, 2021
@felixfbecker felixfbecker changed the title Calculating width and height of SVG with % is not working Percentage units in nested <svg> is not resolved relative to the inner <svg> before emitting into the output SVG Apr 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants