What
The documentation for 'handling initialisation errors' within the 'Using createAll with your components' section of the docs implies that the onError callback will receive a context object which always includes component, element and config.
However, we return early in createAll if GOV.UK Frontend is not supported. If this happens and an onError callback is provided, the callback is called but the context object only contains component and config. This is because we are not yet in the context of on an individual element, so it makes no sense to include one.
Separately, we also call the onError callback from initAll if GOV.UK Frontend is not supported. In this case, we're not yet in the context of a specific component or element, so the context object only includes config.
This is arguably a different context as this part of the documentation deals with createAll, but we don't document how the onError callback works in the context of initAll.
I'm also not sure that it makes sense for this documentation to only exist within the 'Building your own JavaScript components', as it's also relevant for users who are only using our components but want to handle any errors that come from them.
Why
Our documentation should accurately reflect how things work, in a way that's easy for users to understand.
Who needs to know about this
Developers, tech writers
Done when
What
The documentation for 'handling initialisation errors' within the 'Using createAll with your components' section of the docs implies that the
onErrorcallback will receive acontextobject which always includescomponent,elementandconfig.However, we return early in
createAllif GOV.UK Frontend is not supported. If this happens and anonErrorcallback is provided, the callback is called but the context object only containscomponentandconfig. This is because we are not yet in the context of on an individual element, so it makes no sense to include one.Separately, we also call the
onErrorcallback frominitAllif GOV.UK Frontend is not supported. In this case, we're not yet in the context of a specific component or element, so thecontextobject only includesconfig.This is arguably a different context as this part of the documentation deals with
createAll, but we don't document how theonErrorcallback works in the context ofinitAll.I'm also not sure that it makes sense for this documentation to only exist within the 'Building your own JavaScript components', as it's also relevant for users who are only using our components but want to handle any errors that come from them.
Why
Our documentation should accurately reflect how things work, in a way that's easy for users to understand.
Who needs to know about this
Developers, tech writers
Done when
onErrorcallback can be called