A sub component that extends a super component inherits the attributes of the super component.
Attribute values are identical at any level of extension. There is an exception to this rule for the body attribute, which we’ll look at more closely soon.
Let’s start with a simple example. c:super has a description attribute with a value of “Default description”,
Note that sub.cmp has access to the inherited description attribute and it has the same value in sub.cmp and super.cmp.
Use <aura:set> in the markup of a sub component to set the value of an inherited attribute.
Inherited body Attribute
Every component inherits the body attribute from <aura:component>. The inheritance behavior of body is different than other attributes. It can have different values at each level of component extension to enable different output from each component in the inheritance chain. This will be clearer when we look at an example.
Any free markup that is not enclosed in another tag is assumed to be part of the body. It’s equivalent to wrapping that free markup inside <aura:set attribute="body">.
The default renderer for a component iterates through its body attribute, renders everything, and passes the rendered data to its super component. The super component can output the data passed to it by including {!v.body} in its markup. If there is no super component, you’ve hit the root component and the data is inserted into document.body.
Let’s look at a simple example to understand how the body attribute behaves at different levels of component extension. We have three components.
c:superBody is the super component. It inherently extends <aura:component>.
At this point, c:superBody doesn’t output anything for {!v.body} as it’s just a placeholder for data that will be passed in by a component that extends c:superBody.
c:subBody extends c:superBody by setting extends="c:superBody" in its <aura:component> tag.