Repository navigation
Error callback for insertHTML and renderHTML
Both functions only had a success callback, so after v0.0.10 a failed load no longer hung but the caller still could not detect it. An optional last parameter has been added:
insertHTML(url, id, runFunction, errorFunction)
renderHTML(id, url, callback, errorCallback)It is called with an Error when the element does not exist, the reply is non-2xx, the network fails, or the request times out. On failure the element is left unchanged and the success callback is not called. Existing three-argument calls keep working and log failures as before.
An exception thrown inside your own success callback is not reported to the error callback, so a bug in your code is not mistaken for a failed load.
Behavior change: insertHTML now treats a non-2xx reply as a failure. It previously injected the server's error page, a 404 page for example, into the element and then called runFunction as if the load had succeeded. renderHTML already behaved this way.
Docs: https://croot.js.org/docs/api/ and https://croot.js.org/docs/element/