DOM Interfaces

 

The nsIDOMDocumentXBL Interface

The nsIDOMDocumentXBL interface contains methods for manipulating XBL bindings. The interface is implemented by all DOM documents.

IDL Definition

interface nsIDOMDocumentXBL {
  NodeList getAnonymousNodes(in Element elt);
  Element getAnonymousElementByAttribute(in Element elt,
                                         in DOMString attrName,
                                         in DOMString attrValue);
  Element getBindingParent(in Node node);
  void loadBindingDocument(in DOMString documentURL);
};

Methods

getAnonymousNodes

The getAnonymousNodes method retrieves the anonymous children of the specified element.

  • Parameters
    • elt - The element to retrieve anonymous children for.
  • Return Value
    • NodeList - The return value of getAnonymousNodes is a NodeList that represents the children of an element after insertion points from its own binding have been applied. This means that, depending on the details regarding the insertion points of the binding, it's possible that some non-anonymous nodes appear in the list. See "Not so anonymous nodes" on mozilla.dev.platform for some discussion about this.

getAnonymousElementByAttribute

The getAnonymousElementByAttribute methods retrieves an anonymous descendant with a specified attribute value. Typically used with an (arbitrary) anonid attribute to retrieve a specific anonymous child in an XBL binding.

  • Parameters
    • elt - The element to retrieve anonymous children for.
    • attrName - The attribute name to look up.
    • attrValue - The attribute value to match.
  • Return Value
    • Element - The return value of getAnonymousElementByAttribute is an anonymous descendant of the given element with matching attribute name and value.

getBindingParent

The getBindingParent method is used to obtain the bound element with the binding attached that is responsible for the generation of the specified anonymous node. This method enables an author to determine the scope of any content node. When content at the document-level scope is passed in as an argument, the property's value is null.

  • Parameters
    • node - The node for which the bound element responsible for generation is desired.
  • Return Value
    • Element - The return value of getBindingParent is the element responsible for the given anonymous node.

loadBindingDocument

The loadBindingDocument method can be used to synchronously obtain the specified binding document for use within a particular document (the one on which the loadBindingDocument method was invoked). The binding document can then be modified programmatically using the DOM. Any subsequent bindings that are attached to elements within the document will be constructed from the modified binding document.

  • Parameters
    • documentURL of type DOMString - The URL of a binding document.
  • No Return Value

Example

The following snippet checks to see if any anonymous child of "element" is itself an element.

if (element.ownerDocument instanceof Ci.nsIDOMDocumentXBL)
{
    var anonChildren = element.ownerDocument.getAnonymousNodes(element);
    if (anonChildren)
    {
        for (var i = 0; i < anonChildren.length; i++)
        {
            if (anonChildren[i].nodeType == 1)
                return false;
        }
    }
}
return true; 

Document Tags and Contributors

 Last updated by: SergeyAvd,