I am trying to see how I am able to find email and phone links within the LWC DOM. I am well aware that it is shadow DOM so I did try to detect the shadow root inside my BFS implementation Here is the code sample

  findLinksInSFDC: function (component) {
    const links = [];
    const queue = [document.documentElement];
    while (queue.length > 0) {
      const node = queue.shift();
      if (node.tagName === "A") {
        const href = node.getAttribute("href");
        if (href && (href.startsWith("tel:") || href.startsWith("mailto:"))) {

      if (node.shadowRoot) {

      if (node.children) {
        for (let i = 0; i < node.children.length; i++) {
    return links;

When I got to the point at "one-record-home-flexipage2", everything stops. Although I inspected the element and confirm that it has shadowRoot property, but when I tried to print it, it returned null.

This helper method [findLinksInSFDC] is used in rerender in the renderer.

  • I suggest that you are trying to do something you simply should not be doing and there's probably a better way to do it. Why are you doing this?
    – Phil W
    Commented Jan 30 at 18:32
  • 1
    What are you trying to do? This seems like an X-Y Problem.
    – sfdcfox
    Commented Jan 30 at 20:55
  • We have our custom emailing and calling tool implemented in the utility bar. We want clicking on the phone and mail links open the tools instead of the Application on the computer.
    – Liu Hantao
    Commented Jan 31 at 4:38


You must log in to answer this question.

Browse other questions tagged .