| 1 |
<?xml version="1.0" standalone="no"?> |
| 2 |
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" |
| 3 |
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"> |
| 4 |
|
| 5 |
<!-- |
| 6 |
|
| 7 |
Licensed to the Apache Software Foundation (ASF) under one or more |
| 8 |
contributor license agreements. See the NOTICE file distributed with |
| 9 |
this work for additional information regarding copyright ownership. |
| 10 |
The ASF licenses this file to You under the Apache License, Version 2.0 |
| 11 |
(the "License"); you may not use this file except in compliance with |
| 12 |
the License. You may obtain a copy of the License at |
| 13 |
|
| 14 |
http://www.apache.org/licenses/LICENSE-2.0 |
| 15 |
|
| 16 |
Unless required by applicable law or agreed to in writing, software |
| 17 |
distributed under the License is distributed on an "AS IS" BASIS, |
| 18 |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 19 |
See the License for the specific language governing permissions and |
| 20 |
limitations under the License. |
| 21 |
|
| 22 |
--> |
| 23 |
<!-- ====================================================================== --> |
| 24 |
<!-- append child test --> |
| 25 |
<!-- --> |
| 26 |
<!-- @author [email protected] --> |
| 27 |
<!-- @version $Id$ --> |
| 28 |
<!-- ====================================================================== --> |
| 29 |
|
| 30 |
<?xml-stylesheet type="text/css" href="../../resources/style/test.css" ?> |
| 31 |
|
| 32 |
<svg xmlns="http://www.w3.org/2000/svg" |
| 33 |
xmlns:xlink="http://www.w3.org/1999/xlink" |
| 34 |
id="body" width="450" height="500" viewBox="0 0 450 500"> |
| 35 |
|
| 36 |
<title>removeChild test 'onload'</title> |
| 37 |
|
| 38 |
<text x="50%" y="45" class="title">removeChild test 'onload'</text> |
| 39 |
|
| 40 |
<script type="text/ecmascript"> |
| 41 |
|
| 42 |
var svgNamespaceURI = "http://www.w3.org/2000/svg"; |
| 43 |
var TEXT_NODE = 3; |
| 44 |
|
| 45 |
function remove(evt) { |
| 46 |
var g = evt.currentTarget; |
| 47 |
// First remove any text node children. |
| 48 |
var fc = g.firstChild; |
| 49 |
while (fc) { |
| 50 |
if (fc.getNodeType() == TEXT_NODE) { |
| 51 |
var x = fc; |
| 52 |
fc = fc.nextSibling; |
| 53 |
g.removeChild(x); |
| 54 |
} else { |
| 55 |
fc = fc.nextSibling; |
| 56 |
} |
| 57 |
} |
| 58 |
g.removeChild(g.firstChild); // remove grey |
| 59 |
g.removeChild(g.firstChild.nextSibling); // remove crimson |
| 60 |
g.removeChild(g.firstChild.nextSibling); // remove orange |
| 61 |
g.removeChild(g.firstChild); // remove gold |
| 62 |
} |
| 63 |
|
| 64 |
function removeAll(evt) { |
| 65 |
var g = evt.currentTarget; |
| 66 |
while (g.hasChildNodes()) { |
| 67 |
g.removeChild(g.firstChild); |
| 68 |
} |
| 69 |
} |
| 70 |
|
| 71 |
</script> |
| 72 |
|
| 73 |
<g onload="remove(evt)"> |
| 74 |
<rect x="100" y="100" width="100" height="100" style="fill:#eee"/> |
| 75 |
<rect x="150" y="100" width="100" height="100" style="fill:gold"/> |
| 76 |
<rect x="200" y="100" width="100" height="100" style="fill:crimson"/> |
| 77 |
<rect x="250" y="100" width="100" height="100" style="fill:orange"/> |
| 78 |
</g> |
| 79 |
|
| 80 |
<g onload="removeAll(evt)"> |
| 81 |
<rect x="100" y="300" width="100" height="100" style="fill:#eee"/> |
| 82 |
<rect x="150" y="300" width="100" height="100" style="fill:gold"/> |
| 83 |
<rect x="200" y="300" width="100" height="100" style="fill:crimson"/> |
| 84 |
<rect x="250" y="300" width="100" height="100" style="fill:orange"/> |
| 85 |
</g> |
| 86 |
|
| 87 |
</svg> |