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-svg-viewbox-only.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<title>preserveAspectRatio none on an image element stretches a referenced SVG that has only a viewBox</title>
<link rel="author" title="Sam Weinig" href="mailto:sam@webkit.org">
<link rel="match" href="image-preserveaspectratio-none-svg-viewbox-only-ref.html">
<meta name="assert" content="With preserveAspectRatio none, the image-rendering rectangle is the whole 200x100 positioning rectangle, and a square SVG with only a viewBox is stretched to fill it rather than being fitted inside it by its own preserveAspectRatio: its blue left half covers the left 100x100 and its green right half the right 100x100.">
<style>
body { margin: 0; }
</style>
<!-- Red is painted where the image must be, so an image drawn anywhere else, or not stretched, leaves red showing. -->
<svg width="220" height="120">
<rect x="10" y="10" width="200" 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>"/>
</svg>