Skip to content
This repository has been archived by the owner on Mar 6, 2024. It is now read-only.

Web platform incompatibility for Image's src property #3719

Open
zaygraveyard opened this issue Mar 29, 2023 · 0 comments
Open

Web platform incompatibility for Image's src property #3719

zaygraveyard opened this issue Mar 29, 2023 · 0 comments

Comments

@zaygraveyard
Copy link

zaygraveyard commented Mar 29, 2023

The Image's src instance property is configurable and enumerable in all browsers except Focus for iOS.
This incompatibility is causing https://ovl.oceandatalab.com to not load properly.

It's caused by the following code that replaces the src property with a non-configurable and non-enumerable one (which is the default when using Object.defineProperty).

var originalImageSrc = Object.getOwnPropertyDescriptor(Image.prototype, 'src');
delete Image.prototype.src;
Object.defineProperty(Image.prototype, 'src', {
get: function() {
return originalImageSrc.get.call(this);
},
set: function(value) {
messageHandler.postMessage({ url: value })
originalImageSrc.set.call(this, value);
}
});

This issue can easily fixed by setting both configurable and enumerable to true, like this:

  var originalImageSrc = Object.getOwnPropertyDescriptor(Image.prototype, 'src');
  delete Image.prototype.src;
  Object.defineProperty(Image.prototype, 'src', {
    configurable: true,
    enumerable: true,
    get: function() {
      return originalImageSrc.get.call(this);
    },
    set: function(value) {
      messageHandler.postMessage({ url: value })
      originalImageSrc.set.call(this, value);
    }
  });

I'm open to submitting a PR.

PS: I'm one of the developers of the linked page that is not loading properly.

┆Issue is synchronized with this Jira Task

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant