braposo / react-responsive-picture

A future-proof responsive image component that supports latest Picture specification

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Prop updates are not correctly handled with Picturefill

EmilEriksen opened this issue · comments

According to the Picturefill website

If you dynamically change the srcset, sizes attributes, or modify source elements, please use this reevaluate option and provide an array or array-like object of your mutated img elements. As an alternative the mutation plugin can be used.

picturefill({
  reevaluate: true,
  elements: [ document.getElementById( "myImg" ) ]
});

I don't believe this is being done at the moment, and I believe it's causing a bug I'm facing where I'm doing exactly that

Hey @EmilEriksen are you able to provide a bit more context about the bug you're experiencing?

Is that happening in all browsers or older ones?

We're currently just using the simplest call to picturefill so that's definitely not supported at the moment but I'm just trying to understand and recreate that bug you've mentioned.

Yes, of course. I've created an example here. If you open it in a modern browser it'll play a slideshow of images but in IE 11 nothing happens because Picturefill is not being told that the srcset has been updated. If you look in the DOM explorer you can see that the srcset attribute is updated but src is not. This should happen in all older browsers that require Picturefill to work but I've only tested it in IE 11.