Fri, 16 Jan 2015 18:13:44 +0100
Integrate suggestion from review to improve consistency with existing code.
michael@0 | 1 | <!-- |
michael@0 | 2 | Any copyright is dedicated to the Public Domain. |
michael@0 | 3 | http://creativecommons.org/publicdomain/zero/1.0/ |
michael@0 | 4 | --> |
michael@0 | 5 | <svg xmlns="http://www.w3.org/2000/svg" version="1.1" |
michael@0 | 6 | xmlns:xlink="http://www.w3.org/1999/xlink"> |
michael@0 | 7 | <title>Testing that dynamic changes to the element for a given ID are reflected in 'use'</title> |
michael@0 | 8 | |
michael@0 | 9 | <use id="u1" x="10%" xlink:href="#r1"/> |
michael@0 | 10 | <script> |
michael@0 | 11 | // force frame construction; test that parsing "r1" after frame construction |
michael@0 | 12 | // is still bound to "u1" eventually |
michael@0 | 13 | var rect = document.getElementById("u1").getBoundingClientRect(); |
michael@0 | 14 | </script> |
michael@0 | 15 | <rect width="11%" height="100%" fill="lime" id="r1"/> |
michael@0 | 16 | |
michael@0 | 17 | <rect width="11%" height="100%" fill="lime" id="x"/> |
michael@0 | 18 | <use id="u2" x="20%" xlink:href="#r2"/> |
michael@0 | 19 | <script> |
michael@0 | 20 | var rect = document.getElementById("u2").getBoundingClientRect(); |
michael@0 | 21 | // check that changing an id to "r2" lets u2 find it |
michael@0 | 22 | var r2 = document.getElementById("x"); |
michael@0 | 23 | r2.setAttribute("id", "r2"); |
michael@0 | 24 | </script> |
michael@0 | 25 | |
michael@0 | 26 | <rect width="10%" height="100%" fill="red" id="r3"/> |
michael@0 | 27 | <rect width="11%" height="100%" fill="lime" id="r3"/> |
michael@0 | 28 | <use id="u3" x="30%" xlink:href="#r3"/> |
michael@0 | 29 | <script> |
michael@0 | 30 | var rect = document.getElementById("u3").getBoundingClientRect(); |
michael@0 | 31 | // check that removing the bad r3 lets u3 find the good one |
michael@0 | 32 | var r3 = document.getElementById("r3"); |
michael@0 | 33 | r3.parentNode.removeChild(r3); |
michael@0 | 34 | </script> |
michael@0 | 35 | |
michael@0 | 36 | <rect width="10%" height="100%" fill="red" id="r4"/> |
michael@0 | 37 | <rect width="11%" height="100%" fill="lime" id="r4"/> |
michael@0 | 38 | <use id="u4" x="40%" xlink:href="#r4"/> |
michael@0 | 39 | <script> |
michael@0 | 40 | var rect = document.getElementById("u4").getBoundingClientRect(); |
michael@0 | 41 | // check that renaming the bad r4 lets u4 find the good one |
michael@0 | 42 | var r4 = document.getElementById("r4"); |
michael@0 | 43 | r4.removeAttribute("id"); |
michael@0 | 44 | </script> |
michael@0 | 45 | |
michael@0 | 46 | <rect width="10%" height="100%" fill="red" id="r5"/> |
michael@0 | 47 | <use id="u5" x="50%" xlink:href="#r5"/> |
michael@0 | 48 | <script> |
michael@0 | 49 | var rect = document.getElementById("u5").getBoundingClientRect(); |
michael@0 | 50 | // check that changing u5's reference works |
michael@0 | 51 | var u5 = document.getElementById("u5"); |
michael@0 | 52 | u5.setAttributeNS("http://www.w3.org/1999/xlink", "href", "#r1"); |
michael@0 | 53 | </script> |
michael@0 | 54 | |
michael@0 | 55 | <rect width="10%" height="100%" fill="red" id="r6"/> |
michael@0 | 56 | <rect width="11%" height="100%" fill="lime" id="r6-2"/> |
michael@0 | 57 | <use id="u6" x="60%" xlink:href="#r6"/> |
michael@0 | 58 | <script> |
michael@0 | 59 | var rect = document.getElementById("u6").getBoundingClientRect(); |
michael@0 | 60 | // check that inserting a good element before the bad r6 works |
michael@0 | 61 | var r6 = document.getElementById("r6-2"); |
michael@0 | 62 | r6.parentNode.removeChild(r6); |
michael@0 | 63 | r6.setAttribute("id", "r6"); |
michael@0 | 64 | document.documentElement.insertBefore(r6, document.documentElement.firstChild); |
michael@0 | 65 | </script> |
michael@0 | 66 | |
michael@0 | 67 | <rect width="11%" height="100%" fill="lime" id="r7"/> |
michael@0 | 68 | <rect width="10%" height="100%" fill="red" id="r7-2"/> |
michael@0 | 69 | <use id="u7" x="70%" xlink:href="#r7"/> |
michael@0 | 70 | <script> |
michael@0 | 71 | var rect = document.getElementById("u7").getBoundingClientRect(); |
michael@0 | 72 | // check that inserting a bad element after a good one doesn't break anything |
michael@0 | 73 | var r7 = document.getElementById("r7-2"); |
michael@0 | 74 | r7.parentNode.removeChild(r7); |
michael@0 | 75 | r7.setAttribute("id", "r7"); |
michael@0 | 76 | document.documentElement.appendChild(r7); |
michael@0 | 77 | </script> |
michael@0 | 78 | |
michael@0 | 79 | <rect width="11%" height="100%" fill="lime" id="r8-2"/> |
michael@0 | 80 | <rect width="10%" height="100%" fill="red" id="r8"/> |
michael@0 | 81 | <use id="u8" x="80%" xlink:href="#r8"/> |
michael@0 | 82 | <script> |
michael@0 | 83 | var rect = document.getElementById("u8").getBoundingClientRect(); |
michael@0 | 84 | // check that renaming a good element to r8 works |
michael@0 | 85 | var r8 = document.getElementById("r8-2"); |
michael@0 | 86 | r8.setAttribute("id", "r8"); |
michael@0 | 87 | </script> |
michael@0 | 88 | |
michael@0 | 89 | <rect width="11%" height="100%" fill="lime"/> |
michael@0 | 90 | <rect x="90%" width="11%" height="100%" fill="lime"/> |
michael@0 | 91 | </svg> |