Repository navigation
SVG: read the x, y, width and height of an <image> as lengths, so that they may have a unit - #2161
Open
RavSinghChandan wants to merge 1 commit into
Open
RavSinghChandan wants to merge 1 commit into
RavSinghChandan wants to merge 1 commit into
Conversation
…t they may have a unit
RavSinghChandan
force-pushed
the
svg-image-length-units
branch
from
November 10, 2026 14:10
dd9bedc to
99ca06b
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
An
<image>whosex,y,widthorheighthas a unit fails:build_image()reads these attributes withfloat(), while the other shapes (<rect>,<circle>, ...) and the root<svg>read their lengths withresolve_length(). The logo of narwhals (docs/assets/logo.svg) is such a file:<svg width="342px" height="342px">with<image x="0px" y="0px" width="342px" height="342px">.build_image()now usesresolve_length()for the four attributes too, so342pxbecomes 256.5, the same size as the<svg>it fills, and a unitless value is unchanged. The narwhals logo renders as it does in a browser.test_svg_image_length_unitschecks the position and size of an<image>with no unit,px,ptandmm; the three cases with a unit fail on master. The SVG tests, black, pylint, mypy and pyright pass