struct-dom-04-b
|
SVG Image
|
PNG Image
|
struct-dom-04-b
Checks if DOM/ECMA Script binding is supported. Checks support for the
hasFeature method on the DOMImplementation.
var featureStrings = new Array();
var length = 0;
/*
featureStrings[length++] = "xml";
featureStrings[length++] = "stylesheets";
featureStrings[length++] = "views";
featureStrings[length++] = "css2";
featureStrings[length++] = "events";
featureStrings[length++] = "uievents ";
featureStrings[length++] = "mouseevents";
featureStrings[length++] = "mutationevents";
featureStrings[length++] = "traversal";
featureStrings[length++] = "org.w3c.svg";
*/
featureStrings[length++] = "org.w3c.svg.lang";
featureStrings[length++] = "org.w3c.svg.dynamic";
featureStrings[length++] = "org.w3c.svg.static";
featureStrings[length++] = "org.w3c.dom.svg";
featureStrings[length++] = "org.w3c.svg";
/*
featureStrings[length++] = "org.w3c.dom.svg.static";
featureStrings[length++] = "org.w3c.dom.svg.animation";
featureStrings[length++] = "org.w3c.dom.svg.dynamic";
featureStrings[length++] = "org.w3c.svg.all";
featureStrings[length++] = "org.w3c.dom.svg.all";
*/
var svg_ns = "http://www.w3.org/2000/svg"
function domTest(evt) {
// Get Document
var target = evt.target;
var doc = target.ownerDocument;
// Get DOMImplementation
var domImpl = doc.implementation;
//
// Iterate through the feature strings
//
for(var i=0; i<featureStrings.length; i++){
var supports = domImpl.hasFeature(featureStrings[i], '2.0');
//
// if time, pretty up by putting xml to traveral in a left column and
// org.w3c.svg to org.w3c.dom.svg.all in a right column; add an extra
// parameter to addTextElemen t for x coord, and test if i < 9
//
addTextElement(featureStrings[i], supports, doc, target, (45 + 40*i));
}
}
function addTextElement(label, value, doc, svg, y){
var newText = doc.createElementNS(svg_ns, 'text');
newText.setAttribute('font-size', '30');
newText.setAttribute('x', '5');
newText.setAttribute('y', y);
var textValue = label;
var textContent = doc.createTextNode(textValue);
newText.appendChild(textContent);
svg.appendChild(newText);
newText = doc.createElementNS(svg_ns, 'text');
newText.setAttribute('font-size', '30');
newText.setAttribute('x', '385');
newText.setAttribute('y', y);
textValue = value;
textContent = doc.createTextNode(textValue);
newText.appendChild(textContent);
svg.appendChild(newText);
}
$Revision: 1.1 $
|
|
|
Verify the basic capability to handle the hasFeature DOMImplementation method.
The DOMImplementation instance is retreived from the Document instance. Then,
its hasFeature method is invoked on the various SVG feature strings.
The test displays the set of SVG feature strings and, next to them, a text
string that shows whether the feature is supported or not.
Note that the test passes whether or not the feature is supported (i.e., true or
false are valid). The test fails if no value (true or false) appears next to the feature string
value.
Note that this test uses the 'onload' event on the root svg element.
The rendered picture should match the reference image, except for the yes and
no values which may differ depending on the implementation.