prefixfree icon indicating copy to clipboard operation
prefixfree copied to clipboard

Extend `CSSStyleDeclaration.prototype`?

Open timdream opened this issue 10 years ago • 0 comments

I just realized I can do this to make, for example, el.style.flex work on Safari:

  if (!('flex' in document.body.style) &&
      ('webkitFlex' in document.body.style)) {
    Object.defineProperty(CSSStyleDeclaration.prototype, 'flex', {
      get: function() {
        return this.webkitFlex;
      },
      set: function(val) {
        return (this.webkitFlex = val);
      }
    })
  }

Is it better compare to mutation observer, which change the property in another function loop?

timdream avatar Jan 28 '15 04:01 timdream