Closed jgogstad closed 7 years ago
How about simply adding an Element.prototype.remove()
polyfill inside your project for IE under Edge
?
So that react-grecaptcha
will not polluting global environment of consumer's project.
if (!('remove' in Element.prototype)) {
Element.prototype.remove = function() {
if (this.parentNode) {
this.parentNode.removeChild(this);
}
};
}
ref: https://developer.mozilla.org/en-US/docs/Web/API/ChildNode/remove
Or, maybe we could use babel-plugin-transform-runtime in react-grecaptcha
.
What about changing the code to?
var scriptElement = document.getElementById(ID);
scriptElement.parentNode.removeChild(scriptElement);
@jcdekoning Thanks! 🙌
Sorry I dont have IE browser on my MacBook, please verify the released changes with version v1.1.2
so that I could close it. cc @jgogstad
Close it. Please feel free to reopen this issue if the problem still occurs with a newer version.
When unmounting the recaptcha in IE, an exception is thrown
Object doesn't support property or method 'remove'
, due to https://github.com/evenchange4/react-grecaptcha/blob/master/src/Recaptcha.js#L48. Which of course is becauseremove
isn't available in IE.