blockly > FocusableTreeTraverser > findFocusableNodeFor

FocusableTreeTraverser.findFocusableNodeFor() method

Returns the IFocusableNode corresponding to the specified HTML or SVG element iff it's the root element or a descendent of the root element of the specified IFocusableTree.

If the element exists within the specified tree's DOM structure but does not directly correspond to a node, the nearest parent node (or the tree's root) will be returned to represent the provided element.

If the tree contains another nested IFocusableTree, the nested tree may be traversed but its nodes will never be returned here per the contract of IFocusableTree.lookUpFocusableNode.

The provided element must have a non-null, non-empty ID that conforms to the contract mentioned in IFocusableNode.

Signature:

static findFocusableNodeFor(element: HTMLElement | SVGElement, tree: IFocusableTree): IFocusableNode | null;

Parameters

Parameter Type Description
element HTMLElement | SVGElement The HTML or SVG element being sought.
tree IFocusableTree The tree under which the provided element may be a descendant.

Returns:

IFocusableNode | null

The matching IFocusableNode, or null if there is no match.