stampit-org / stampit

OOP is better with stamps: Composable object factories.
https://stampit.js.org
MIT License
3.02k stars 102 forks source link

IE11 unsupported without Object.assign polyfill #319

Closed Mustack closed 7 years ago

Mustack commented 7 years ago

Stampit makes use of Object.assign(), which is not supported in IE11. I propose that a library be used to address this:

https://www.npmjs.com/package/object-assign

I'll make a PR soon. I need this for my library because I need IE11 support and I would rather not have to force downstream developers to include a polyfill.

danielkcz commented 7 years ago

Closed by comment

koresar commented 7 years ago

Without an internal Object.assign reimplementation: Estimating dist/stampit.umd.min.js: 5.16 KB, GZIP : 1.8 KB

With it: Estimating dist/stampit.umd.min.js: 5.26 KB, GZIP : 1.84 KB

The implementation look like this:

export const assign = Object.assign || function assign(to) {
  for (let s = 1; s < arguments.length; s += 1) {
    const from = arguments[s];

    for (const key in from) {
      to[key] = from[key];
    }
  }

  return to;
};

I know it's unsafe, but works for the internal object merging.

I would rather release stampit v3 with this thing, but we should clearly state that "IE11 unit tests where never run, we do not have an ability to run stampit tests in IE11".

(Going to cross post this to the other thread.)

koresar commented 7 years ago

Another proposed fix is in #321

koresar commented 7 years ago

Aaand done! Released v3.2.0. https://github.com/stampit-org/stampit/releases/tag/v3.2.0 Not polyfiling anymore.