Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /svg/coordinate-systems/transform-translate-single-parameter.html - WPT Dashboard Interop Dashboard
<!DOCTYPE HTML>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body>
<rect x="10" y="10" width="180" height="80" fill="red" />
</svg>
<script>
test(() => {
const rectElement = document.querySelector("rect");
// Apply single parameter translate - should behave as translate(100, 0)
rectElement.setAttribute("transform", "translate(100)");
assert_equals(rectElement.getAttribute('transform'), "translate(100)");
assert_equals(rectElement.transform.baseVal.getItem(0).matrix.e, 100);
assert_equals(rectElement.transform.baseVal.getItem(0).matrix.f, 0);
}, 'Dynamic update of transform; setAttribute()');
</script>
</body>
</html>