Full version, Basic version

Specification link: 5.11 DOM interfaces

struct-dom-01-b ← index → struct-dom-03-b

# struct-dom-02-b
SVG Image | PNG Image
struct-dom-02-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"; 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 &lt; 9 // addTextElement(featureStrings[i], supports, doc, target, (55 + 55*i)); } } function addTextElement(label, value, doc, svg, y){ var newText = doc.createElementNS(svg_ns, 'text'); newText.setAttribute('font-size', '30'); newText.setAttribute('x', '10'); 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', '340'); 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.

struct-dom-01-b ← index → struct-dom-03-b