<!doctype html>
<html class="reftest-wait">
<title>SourceGraphic is invalidated when removing element from the document</title>
<link rel="help" href="https://drafts.fxtf.org/filter-effects-1/#attr-valuedef-in-sourcegraphic">
<link rel="match" href="reference/green-100x100.html">
<script src="/common/rendering-utils.js"></script>
<script src="/common/reftest-wait.js"></script>
<svg>
  <filter id="f">
    <feMerge><feMergeNode/></feMerge>
  </filter>
  <rect width="100" height="100" fill="red"/>
  <rect id="target" width="50" height="100" fill="green" filter="url(#f)"/>
</svg>
<script>
  waitForAtLeastOneFrame().then(() => {
    let rect = document.getElementById('target');
    let svg = rect.parentNode;
    rect.remove();
    rect.setAttribute('width', '100');
    svg.appendChild(rect);
    takeScreenshot();
  });
</script>
