So basically this theme has a "stacked Images" feature. where you can use the alt text field to include a tag that will help the theme to stack the images according to a variant.
Stacked images do work well if I add an alt text to it.
But if we need to mimic default shopify functionality, I had to add an exlamation mark at line 8985 of theme.js. Line 13 in my gist example above.
Because Line 13 always resorted to go to the else part of the if statement, and for some reason Array.from(target.parentElement.children).indexOf(target)
always returned a data index of zero. i think this is by design because the theme always expects images to be stacked. So my ! disabled the stack. stack feature
Now I am trying to find the stacked image setting and how its computed.