-
Notifications
You must be signed in to change notification settings - Fork 25
Description
Found an interesting issue with the template engine of Dug.js.
If you specify a wrong url like:
endpoint: 'https://api.pinterest.com/foobar
The script will just give a 404 correctly and do nothing.
Now if you go deeper and just add a little typo in the url:
endpoint: 'https://api.pinterest.com/v3/pidgets/boards/rogieking/my-illustration-style-typo/pins/'
Chrome will crash because the template engine will keep looking for data.data.pins.
A workaround for this is to set data.data.pins to something:
beforeRender: function( data ){ if (data.status === "failure") { // Hack: give something to the template to be happy data.data = { pins: [] }; (...)
So the template will get an empty object and do nothing.
As far as I understood the "error" callback will only be called if there's an error such a network error. If you have a typo in the endpoint url, the call will be a success but with empty data (without pins). So the error callback won't be called and the template will hang.