// Polyfill Element.remove on IE11
// from:https://github.com/jserz/js_piece/blob/master/DOM/ChildNode/remove()/remove().md
(function(arr) {
  arr.forEach(function(item) {
    if (Object.prototype.hasOwnProperty.call(item, 'remove')) {
      return;
    }
    Object.defineProperty(item, 'remove', {
      configurable: true,
      enumerable: true,
      writable: true,
      value: function remove() {
        this.parentNode.removeChild(this);
      },
    });
  });
})([Element.prototype, CharacterData.prototype, DocumentType.prototype]);

// Polyfill Element.remove on IE11
// from:https://github.com/jserz/js_piece/blob/master/DOM/ChildNode/remove()/remove().md

const classPrototypes =
  [window.Element, window.CharacterData,window.DocumentType]
    .filter( (klass) => klass )
    .map( (klass) => klass.prototype );

(function(arr) {
  arr.forEach(function(item) {
    if (Object.prototype.hasOwnProperty.call(item, 'remove')) {
      return;
    }
    Object.defineProperty(item, 'remove', {
      configurable: true,
      enumerable: true,
      writable: true,
      value: function remove() {
        this.parentNode.removeChild(this);
      },
    });
  });
})(classPrototypes);

Fix for running in Fastboot
Fix for running in Fastboot

Fastboot does not have the concept of Element, CharacterData and
presumably DocumentType.  Inclusion of this polyfill thus makes
Fastboot crash early.

Implementation may well be changed to check for IE11 instead of
checking if the entities exist.  I opted for the latter as the
polyfill might support other cases now, or in the future.

Further, I based myself on fetching these entities from window as
TypeScript gave errors if I chose not to.
