struct-dom-06-b
|
SVG Image
|
PNG Image
|
struct-dom-06-b
Checks if DOM ECMA Script binding is supported
function domTest(evt) {
// Get Document
var target = evt.target;
var doc = target.ownerDocument;
//
// Test attribute modification
//
var attributeErrorRect = doc.getElementById('attributeErrorRect');
attributeErrorRect.setAttribute('width', '0')
attributeErrorRect.setAttribute('height', '0');
//
// Test removing element from DOM tree
//
var elementErrorText = doc.getElementById('elementErrorText');
var parent = elementErrorText.parentNode;
parent.removeChild(elementErrorText);
//
// Test adding element to the DOM tree
//
var svg_ns = "http://www.w3.org/2000/svg"
var newText = doc.createElementNS(svg_ns, 'text');
newText.setAttribute('x', '50');
newText.setAttribute('y', '200');
var textContent = doc.createTextNode('DOM API is supported');
newText.appendChild(textContent);
parent.appendChild(newText);
}
Removing DOM Elements is not supported
$Revision: 1.3 $
|
|
|
Verify the basic capability to handle the DOM API. The test is composed of a top
level svg element with an onload event handler. This handler invokes core (i.e., non
SVG specific) DOM API methods to modify the document's content: it removes an element,
modifies an attribute and adds elements.
If an implementation supports the ECMA Script DOM binding, then the image
should show the following text: "The DOM API is supported". Otherwise, the following
will show: "Removing DOM elements is not supported", and the background will be red.
The rendered picture should match the reference image.