5

When multiple aura:if are nested together, I'm getting an error like the following:

Access Check Failed! AttributeSet.get(): attribute 'value2' of component 'markup://c:demo1 {1:0}' is not visible to 'markup://aura:if {6:0}'.

Example Reproduction

<aura:application >
    <aura:attribute name="value1" type="String" access="private" />
    <aura:attribute name="value2" type="String" access="private" />
    <lightning:input value="{!v.value1}" label="Value 1" placeholder="Enter 'a'" />
    <aura:if isTrue="{!v.value1 eq 'a'}">
        <lightning:input value="{!v.value2}" label="Value 2" placeholder="Enter 'b'" />
        <aura:if isTrue="{!v.value2 eq 'b'}">
            <lightning:input label="Value 3" value="{!join(' ',v.value1,v.value2)}" />
        </aura:if>
    </aura:if>
</aura:application>

This occurs when the attribute is private, and there's at least two levels of aura:if statements. It also only occurs after causing the innermost lightning:input to render, then subsequently unrendering it by changing Value 1 a few times. Once this happens, all further renderings will cause this error.

Why is this happening, and what can I do to avoid it?

5

This is a bug with access checking in the Lightning Web Component framework, and may manifest as an error in Aura components when this happens. There are a few different ways to reproduce it; the one in the answer is just one form. The known solutions are as follows:

Make The Attribute Public

The access exception will only occur on private attributes.

Avoid aura:if

The way aura:if rerenders causes the bug to surface in LWC. Instead, hide the elements using normal CSS (or SLDS). Here's an example fix:

<aura:application extends="force:slds">
    <aura:attribute name="value1" type="String" access="private" />
    <aura:attribute name="value2" type="String" access="private" />
    <lightning:input value="{!v.value1}" label="Value 1" placeholder="Enter 'a'" />
    <div class="{!v.value1 eq 'a'?'':'slds-hide'}">
        <lightning:input value="{!v.value2}" label="Value 2" placeholder="Enter 'b'" />
        <div class="{!v.value2 eq 'b'?'':'slds-hide'}">
            <lightning:input label="Value 3" value="{!join(' ',v.value1,v.value2)}" />
        </div>
    </div>
</aura:application>

Avoid Usage of LWC Components

Using any component that is a LWC component (basically anything in the lightning namespace) can result in this error. You can replace it with the basic ui namespace component (e.g. ui:inputText instead of lightning:inputText). This will probably not be practical in most applications, but it is a possible workaround.

This has been filed as W-5722782.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.