Skip to main content
In Spring 21 it appears that the Node.getRootNode() function is returning undefined instead of the proper behavior, which is to return the ShadowRoot.  (see https://developer.mozilla.org/en-US/docs/Web/API/Node/getRootNode)

 

Here is a simple component that reproduces the issue:

 

Component

<aura:component implements="flexipage:availableForAllPageTypes" access="global">

    <div id="rooty" aura:id="rooty"/>

</aura:component>

 

Renderer

({

    afterRender : function(component, helper) {

        console.log('root node:');

        console.log(component.find('rooty').getElement().getRootNode());

    }

})

 

Interestingly, it does seem behave correctly inside the Lightning App Builder preview window.  It only returns undefined when you load the actual lightning app/page.  

 

This is causing some big problems for us.  Chart.js relies on this method to behave as defined in the spec and returning undefined breaks it.

 

Has anyone else seen this?  Will this be fixed before Spring 21 is officially released?
9 个回答
  1. 2021年2月23日 09:48
    HI Alex,

    >> Winter 21 org: Does not have Raptor Record Home(RRH) enabled. Load the page and notice where the div is in the dom tree. All the way up to the <body>, you will only notice standard HTML elements.

    >> Spring 21 org: Has Raptor Record Home enabled. In other words, the record detail page is rendered using LWC components. So shadow semantics come into play. Notice where the <div id="rooty"> is in the dom tree. It will be underneath a flexipage-aura-wrapper. That is an LWC component. getRootNode() will stop at the shadow boundary of that lwc component. You will need to use getRootNode({composed: true}).

    >>The Spring org's repro is a pure aura component. Notice in this case you are not using the component inside a record detail page, so RRH is not in play.

    >>Users need to use getRootNode({composed: true}) in case if they are using the component in the record page since RRH is enabled in Spring 21 org.

    Hope this answers your ask. If this information helps, please mark the answer as best.Thank you
0/9000