setFocus()

in src/lib/api/event.replayer.ts [207:228]


  setFocus(activeNode: NodeContext) {
    // only do something if there is an active node
    if (!activeNode || !activeNode.node || !activeNode.nodeKey) {
      return;
    }

    // find the client node in the new client view
    const clientNode = this.findClientNode(activeNode);
    if (clientNode) {
      // set focus on the client node
      clientNode.focus();

      // set selection if a modern browser (i.e. IE9+, etc.)
      const selection = activeNode.selection;
      if ((clientNode as HTMLInputElement).setSelectionRange && selection) {
        try {
          (clientNode as HTMLInputElement)
            .setSelectionRange(selection.start, selection.end, selection.direction);
        } catch (ex) {}
      }
    }
  }