What happened to the component lifecycle hooks in the API documentation? It is clearly referenced in the v2.4 guide, but not in the API docs.
I was confused about the guide showing a this.super() call on a didInsertElement example, and went to go look up the API docs, but was surprised to find it missing. Not even under deprecated.
@Guarav: You’re right - I see it in the code, however it seems that the documentation does not reflect this in the inherited properties.
@rmmpaderes: After a little digging, it appears that the base class defines didInsertElement as follows:
didInsertElement: K,
where K is simply the identity function (return this), so calling this._super() in didInsertElement seems superfluous, as there is no default behavior upon insertion of the element. The only justification I can imagine for continuing to do so is in the case that a default behaviour is introduced in the future.
Yes that’s the reason why it’s best practice to use super, in case that a default behavior is introduced in the future (which I don’t think it will, but you never know ).
Another example is if you have a mixin that implements didInsertElement() inside the component. So in order to execute the didInsertElement() of the component before running the one in the mixin, you use super. If however, you’re absolutely sure that it will never happen then feel free to not omit. But again, with the first reason above, it should be sufficient to convince you to use it as best practice.