Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /css/css-images/object-view-box-embedded-svg-dynamic-change.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<html class="reftest-wait">
<title>CSS Test: changing 'object-view-box' on an SVG document in <object> after it loads</title>
<link rel="author" title="Sam Weinig" href="mailto:sam@webkit.org">
<link rel="match" href="object-view-box-embedded-svg-dynamic-change-ref.html">
<meta name="assert" content="Setting, changing and removing object-view-box on an SVG document in an object element after the document loads updates which part of it is shown.">
<style>
object {
width: 48px;
height: 32px;
border: 1px solid gray;
padding: 1px;
float: left;
}
</style>
<object id="a" data="support/colors-16x8.svg" style="object-fit: contain"></object>
<object id="b" data="support/colors-16x8.svg" style="object-fit: contain"></object>
<object id="c" data="support/colors-16x8.svg" style="object-fit: none; object-view-box: inset(0 8px 0 0)"></object>
<script>
let loaded = 0;
function onLoaded() {
if (++loaded < 3)
return;
document.body.offsetHeight;
a.style.objectViewBox = "inset(0 8px 0 0)";
b.style.objectViewBox = "inset(4px 0 0 0)";
c.style.objectViewBox = "none";
requestAnimationFrame(() => requestAnimationFrame(() => document.documentElement.classList.remove("reftest-wait")));
}
for (const element of [a, b, c])
element.addEventListener("load", onLoaded);
</script>
</html>