Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /svg/embedded/image-preserveaspectratio-none-shared-document.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<title>preserveAspectRatio none on one image element does not affect another showing the same SVG</title>
<link rel="author" title="Sam Weinig" href="mailto:sam@webkit.org">
<link rel="match" href="image-preserveaspectratio-none-shared-document-ref.html">
<meta name="assert" content="Two image elements reference the same viewBox-only SVG. The first, with preserveAspectRatio none, stretches it over its whole 200x100 positioning rectangle. The second, with the default xMidYMid meet, fits it as a centered 100x100 square, unaffected by the first.">
<style>
body { margin: 0; }
</style>
<!-- Red is painted where the images must be, so an image drawn anywhere else, or sized like the other one, leaves red showing. -->
<svg width="220" height="240">
<rect x="10" y="10" width="200" height="100" fill="red"/>
<rect x="60" y="130" width="100" height="100" fill="red"/>
<image x="10" y="10" width="200" height="100" preserveAspectRatio="none" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><rect width='100' height='100' fill='rgb(0,128,0)'/><rect width='50' height='100' fill='rgb(0,0,255)'/></svg>"/>
<image x="10" y="130" width="200" height="100" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><rect width='100' height='100' fill='rgb(0,128,0)'/><rect width='50' height='100' fill='rgb(0,0,255)'/></svg>"/>
</svg>