Preact: Element.remove() is unsupported in Internet Explorer

Created on 6 Apr 2017  路  11Comments  路  Source: preactjs/preact

While testing 8.0-beta in IE11 I've run into a problem in unmountComponent() calling .remove() on base:

https://github.com/developit/preact/blob/8/src/vdom/component.js#L266

Changing that line to:

base.parentNode.removeChild(base);

...fixes the problem. I'm not sure if 8.0 is supposed to support IE, but worth keeping in mind.

bug

Most helpful comment

I'm pretty sure IE8 never was supported by Preact. React does support it though.

All 11 comments

If anyone's trying to work around this problem, you can apply a minimum polyfill for the required methods:

(function() {
  function remove() { this.parentNode && this.parentNode.removeChild(this); }
  if (!Element.prototype.remove) Element.prototype.remove = remove;
  if (Text && !Text.prototype.remove) Text.prototype.remove = remove;
})();

I'm not sure if 8.0 is supposed to support IE, but worth keeping in mind.

@developit knows the official status but I'd be tempted to suggest that we drop IE 8 support out of the box if it is starting to conflict with the size/simplicity goals of the project.

This isn't IE8 support, this is IE11 using preact 8.0-beta.

I'm pretty sure IE8 never was supported by Preact. React does support it though.

Ah - this was totally a slip of the mind. .remove() is faster than accessing .parentNode.removeChild(), but it looks like we'll have to bite the bullet.

Hopefully as IE goes the way of the dodo, it will be a thing of the past, as everyone else already supports the living standard:

https://developer.mozilla.org/en-US/docs/Web/API/ChildNode/remove#Browser_compatibility

@KrofDrakula Definitely something to keep on the radar. If this was only in IE9 I'd be tempted to let people polyfill, but 11 is just a bit too far inside the support target.

Fix released in 8.0.1.

This seems to have returned in 10. Should we polyfill now?

@ascorbic thanks for the pointer! Made a PR to fix it again 馃憤

Was this page helpful?
0 / 5 - 0 ratings

Related issues

KnisterPeter picture KnisterPeter  路  3Comments

philipwalton picture philipwalton  路  3Comments

k15a picture k15a  路  3Comments

marcosguti picture marcosguti  路  3Comments

skaraman picture skaraman  路  3Comments