0

"expected end of aura:handler tag: Source"

If my code has a tag on the end and on a new line I receive the above error when trying to save my lightning component.

<aura:handler name="change" value="{!v.key}" action="{!c.selectTab}">
</aura:handler>

If I put it on the same line I am able to save the lightning component.

    <aura:handler name="change" value="{!v.key}" action="{!c.selectTab}"></aura:handler>

Strange thing is, this only looks to occur for aura:handler tags. The aura:attribute below works fine.

<aura:attribute type="String" name="caseId">        
</aura:attribute>

Anyone else see this same issue?

1 Answer 1

2

aura:handler is not meant to have a body. You should be using the short-tag notation:

<aura:handler name="change" value="{!v.key}" action="{!c.selectTab}" />

Other components simply do not care. To be safe, however, if there are no child elements inside a component's body, always use the short-tag notation.

3
  • Yeah, I originally had shorthand but when I use CodeFormatter in Sublime it adds the tag and I have to go back and update it. I see your point on the fact that it cannot have child elements so there is no need to have an end tag in that fashion. Any suggestions on a good code formatter for Sublime and Lightning?
    – Tad
    Commented Jul 18, 2018 at 15:43
  • Then why can I still have the end tag but it only fails when it's on a new line?
    – Tad
    Commented Jul 18, 2018 at 15:55
  • @Tad Because as soon as you add even a single space, you're trying to define a body, but aura:handler doesn't have a body.
    – sfdcfox
    Commented Jul 18, 2018 at 16:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .