Extensions to DOM

Interaction extends DOM with its own functions and constructs for your convenience. These are of course not part of the official DOM specification (although they might be in the future.) However, they are still part of the DOM module and thus prefixed with DOM: when used.

nodep

nodep object [type-constant]+

Predicate to test whether an object is a DOM node. Returns true if the object is a node, NIL if not. If called with one or more type constants, the function returns true only if the object is of the given type or types. The documentation of node-type includes a list of type constants.

(dom:nodep (dom:first-child element) dom:text-node) ; true if the first child of an element is a text node

nodecase

nodecase value (match form)*

Evaluate the form that has a match for the value. In other words, a construct similar to CASE and TYPECASE. Each match should be a symbol for a DOM node type, a DOM node type constant, a string with an element type identifier (a "tag-name"), or a list with multiple matches. T or OTHERWISE matches everything, while the match NIL can be used to handle cases where there are no value.

(dom:nodecase (dom:first-child element)
 (dom:text-node "This is a text node)
 ("p" "A paragraph element")
 (("a" dom:processing-instruction) "An anchor or a processing instruction"))