polyfill-service
Version:
A polyfill combinator
12 lines (10 loc) • 459 B
JavaScript
Document.prototype.replaceWith = Element.prototype.replaceWith = function replaceWith() {
if (this.parentNode) {
this.parentNode.replaceChild(_mutation(arguments), this);
}
};
// Not all UAs support the Text constructor. Polyfill on the Text constructor only where it exists
// TODO: Add a polyfill for the Text constructor, and make it a dependency of this polyfill.
if ('Text' in this) {
Text.prototype.replaceWith = Element.prototype.replaceWith;
}