NodeProxy

Type: Class

Provides a layer around a given node using which access to the node can be intercepted. This will enable Fonto to automatically update the correct parts of a view when the data related to the node that is used in that view changes.

This constructor should not be used by applications. Instances of NodeProxy are obtained when rendering custom widgets or when generating the innerJsonMl for a member of the object CVK family.

Constructor arguments

  1. node

    (Required)

    Type: Node

    The node to wrap.

  2. domFacade

    (Required)

    Type: IDomFacade

    Context used for working with indices.

  3. flags

    (Required)

    Type: ViewFlags

    View flags for the current view

  4. nodeProxyContext

    (Required)

    Type: WeakMap

    Weakmap from node to the corresponding NodeProxy, to guarantee that proxies obtained for the same node are always reference-equal.

Properties

attributes

Type: Array<NodeProxy>

Returns NodeProxies representing all the attributes of the node, assuming it is an Element.

childCount

Type: Number

Returns the number of child nodes of the node.

childElementCount

Type: Number

Returns the number of child elements of the node, assuming it is an Element.

childNodes

Type: Array<NodeProxy>

Returns NodeProxies representing all child nodes under the current node

This introduces dependencies on the childNodes property of this node

data

Type: String

Returns the node's data, assuming it is a CharacterData instance.

firstChild

Type: NodeProxy

Returns a nodeProxy representing the first child of the current node

This introduces dependencies on the childNodes property of this node

lastChild

Type: NodeProxy

Returns a nodeProxy representing the first child of the current node

This introduces dependencies on the childNodes property of this node

length

Type: Number

Returns the length of the node, assuming it is a CharacterData instance.

nextSibling

Type: NodeProxy

Returns a nodeProxy representing the next sibling of the current node

This introduces dependencies on the childNodes property of this node's parentNode

ownerDocument

Type: NodeProxy

Returns a NodeProxy representing the node's owner document.

ownerElement

Type: NodeProxy

Returns a NodeProxy representing the node's owner element.

parentNode

Type: NodeProxy

Returns a NodeProxy representing the parent node of this node.

previousSibling

Type: NodeProxy

Returns a nodeProxy representing the previous sibling of the current node

This introduces dependencies on the childNodes property of this node's parentNode

value

Type: String

Returns the nodes value as data, assuming it is an attribute.

Methods

documentMeetsRequiredAspects

Type: Function

Similar to DocumentsManager#documentMeetsRequiredAspects, but ensures the fragment updates when these aspects change.

Arguments

Returns

findDescendants

Type: Function

Find all descendants of this node matching the descendantSelector.

Using this query avoids recomputing possibly heavy queries every time something under this node changes, replacing it by an indexed lookup.

Arguments

Returns

findRelatedNodes

Type: Function

Perform a complex query for other nodes in the document, starting at the current sourceNode. Using this method avoids taking dependencies on any intermediate result other than the result of the query, which prevents unnecessary redraws.

DO NOT use any node from findRelatedNodes its closure in the query, as that would result in extra dependencies.

Example: (find all nodes with the same data as the current node)

Other

var interestingData = innerNode.firstChild.data;
sourceNode.findRelatedNodes(function query (innerNode) {
    var interestingAncestor = domUtils.findClosestAncestor(innerNode, 'interesting');
    return domQuery.findDescendants(interestingAncestor, 'evenMoreInteresting')
        .filter(function dataFilter (node)) {
            return node.firstChild.data === interestingData;
        });
});

Because this selector could change often, NodeProxy#findRelatedNodes is a better fit for this problem than NodeProxy#findDescendants

Arguments

Returns

getAttribute

Type: Function

Returns the value of the attribute with the given name for the current element, or null if the attribute doesn't exist.

Arguments

Returns

getAttributeNS

Type: Function

Returns the value of the attribute with the given local name and namespace for the current element, or null if the attribute doesn't exist.

Arguments

Returns

getExternalValue

Type: Function

Deprecated!

Use the addExternalValue API to manage external data

Retrieve an external value, not represented in the current document.

Use ExternalDataManager#setExternalData to modify external data values. Note that that method should never be called during rendering. Always call it asynchronously (e.g., from a Promise.then or setTimeout callback) to avoid errors.

Arguments

Returns

getViewFlag

Type: Function

Retrieves a boolean indicating whether the specified view flag is set.

Arguments

Returns

hasAttribute

Type: Function

Returns whether the node has an attribute with the given name

Arguments

Returns

hasAttributeNS

Type: Function

Returns whether the node has an attribute with the given local name and namespace

Arguments

Returns

substringData

Type: Function

Returns a string containing the part of CharacterData.data of the specified length and starting at the specified offset.

Arguments

Returns