PatrickJS / angular-hmr

:fire: Angular Hot Module Replacement for Hot Module Reloading
https://patrickjs.com
Apache License 2.0
506 stars 45 forks source link

removeNgStyles fails on IE 11 #40

Open ghost opened 7 years ago

ghost commented 7 years ago

When removeNgStyles is called on IE 11, the use of remove on the Element fails as IE 11 does not define the remove function on Element.

PatrickJS commented 7 years ago

yeah for ie11 I need to use removeChild()

admosity commented 7 years ago

If you're working with https://github.com/AngularClass/angular-starter, you can drop this polyfill into the dev portion of polyfills to get this working: https://developer.mozilla.org/en-US/docs/Web/API/ChildNode/remove#Polyfill


  // from:https://github.com/jserz/js_piece/blob/master/DOM/ChildNode/remove()/remove().md
  ((arr) => {
    arr.forEach((item) => {
      if (item.hasOwnProperty('remove')) {
        return;
      }
      Object.defineProperty(item, 'remove', {
        configurable: true,
        enumerable: true,
        writable: true,
        // tslint:disable-next-line:only-arrow-functions
        value: function remove() {
          this.parentNode.removeChild(this);
        }
      });
    });
  })([Element.prototype, CharacterData.prototype, DocumentType.prototype]);

image