summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/svg/struct/scripted/svg-getIntersectionList-006.svg
blob: a7b946501377b5512c57286711a51d006d33db62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<svg xmlns="http://www.w3.org/2000/svg"
     xmlns:h="http://www.w3.org/1999/xhtml">
  <title>getIntersectionList() with &lt;use></title>
  <h:link rel="help" href="https://svgwg.org/svg2-draft/struct.html#__svg__SVGSVGElement__getIntersectionList"/>
  <h:script src="/resources/testharness.js"/>
  <h:script src="/resources/testharnessreport.js"/>

  <defs>
    <g id="conn">
      <circle cx="0" cy="0" r="20"/>
    </g>
  </defs>
  <circle cx="65" cy="50" r="20" fill="blue"/>
  <use href="#conn" x="50" y="50" fill="red"/>

  <script>
    function getMatchingLocalNames(x, y) {
      const svg = document.documentElement;
      const rect = Object.assign(svg.createSVGRect(), {x, y, width: 1, height: 1});
      const elems = svg.getIntersectionList(rect, null);
      return Array.from(elems).map(e => e.localName).sort();
    }

    test(t => {
      assert_array_equals(getMatchingLocalNames(50, 60), ['circle', 'use']);
      assert_array_equals(getMatchingLocalNames(0, 0), []);
    });
  </script>
</svg>