I have a custom Lightning component which I have recently added a new attribute to using the Salesforce Developer Console:
<!--Child.cmp-->
<aura:component>
<aura:attribute name="existingAttribute" type="String" required="true"/>
<!-- This is a new attribute I've added today-->
<aura:attribute name="newAttribute" type="String" required="true"/>
<aura:component/>
However, when I come to update the existing code in a parent component - I'm unable to save the component due to an error:
FIELD_INTEGRITY_EXCEPTION
Failed to save Parent.cmp: The attribute "newAttribute" was not found on the COMPONENT markup://c:Child: Source
The code for the parent component contains the component nested deep into the code, using an aura:iteration
and an aura:if
.
<!--Parent.cmp-->
<div>
<form>
<aura:iteration items="{!v.items}" var="item">
<div>
<aura:if isTrue="{!or(or(item.type == 'text', item.type == 'password'), item.type == 'email')}">
<c.Child existingAttribute="{!item.existing}" newAttribute="{!item.new}" />
<aura:if/>
</div>
</aura:iteration>
</form>
</div>
The component can be saved again if I remove the newAttribute
attribute.
From my viewpoint - there is no errors in terms of formatting or setting up the aura:attribute
- and it should work.
And the interesting thing about this - is that the <c.Child />
component line will work if it has a higher level in the depth of the code - it doesn't seem to want to work if it's nested five levels deep...
<!--Parent.cmp-->
<!-- Works -->
<div>
<!-- Works -->
<form>
<!-- Works -->
<aura:iteration items="{!v.items}" var="item">
<!-- Works -->
<div>
<!-- Doesn't Work -->
<aura:if isTrue="{!or(or(item.type == 'text', item.type == 'password'), item.type == 'email')}">
<!-- Doesn't Work -->
<aura:if/>
</div>
</aura:iteration>
</form>
</div>
Am I missing something? Is this a bug? How would I solve this?
Any help would be massively appreciated.
Child
component wasn't successfully deployed to the server after you added that attribute, but that wouldn't explain it working sometimes and not others. Is it possible your actual code is slightly different from the example code you posted?c:Child
and notc.Child
, right? That would definitely cause problems if you did that.c.Child
and it seems to be working ok - can you tell me why I should be usingc:Child
instead? I want to assume it might be something that's more recent?sfdx
to deploy the changes - that seemed to work perfectly fine, so my only conclusion with this is that it's more of a bug with the Developer Console within Salesforce.c:Child
since the original release. Thec.Child
syntax appears nowhere in the documentation at all.