I have a few questions now after attempting the gold challenge.
First of all, why did we change the href attribute in the anchor tags? We go on to prevent the default behavior and we add that data in the data-image-url attribute?
For the extra challenge, the only way I could think of to reset the data-image-url values was to use the image tag’s src values. So, if that was the purpose, then it was good that have the url information twice (once for the anchor tag, and once for the anchor tag’s image tag). Here are the two functions I built to reset the thumbs that way:
function resetThumbURL(thumb) {
'use strict'
// get thumb's image
var image = thumb.querySelector(".thumbnail-image");
// get image's src
var source = image.getAttribute('src');
thumb.setAttribute('data-image-url', source);
} // end resetThumbURL(thumb)
function resetAllThumbURLs() {
'use strict'
var thumbnails = getThumbnailsArray();
thumbnails.forEach(resetThumbURL);
} // end resetALLThumbURLs()
This works, but I feel like perhaps I need to add other data- values to the html. Notice that I am using querySelector
with the class name .thumbnail-image
and also using getAttribute with 'src'
. Should a more robust solution add other data-values to avoid these issues?