javascript - 使用 babel-polyfill 的 ChildNode.remove() polyfill

标签 javascript babeljs polyfills babel-polyfill

我正在使用 ChildNode.remove()并且我由 Mozilla 描述我需要一个用于 IE 的 polyfill。我正在使用配置了 babel-polyfill 的 webpack:

 "babel-polyfill": "^6.13.0",
 "webpack": "^2.4.1",

webpack.config.babel.js:

    entry: ['babel-polyfill', join(__dirname, path, "index.web.js") ],

我的假设是 babel-polyfill 会为我提供我需要的所有常见 polyfill - 但事实并非如此,我在 Internet Explorer 11 中遇到错误。我错过了另一个配置吗?

谢谢

最佳答案

据我所知,babel-polyfill 包只是 polyfill javascript 对象,Childnode.remove() 是 DOM 的一部分,所以 babel 不会做任何事情它。我建议您只使用 Mozilla documentation 中建议的 polyfill .

// from:https://github.com/jserz/js_piece/blob/master/DOM/ChildNode/remove()/remove().md
(function (arr) {
  arr.forEach(function (item) {
    if (item.hasOwnProperty('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]);

关于javascript - 使用 babel-polyfill 的 ChildNode.remove() polyfill,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43756244/

相关文章:

javascript - 有没有办法让嵌入获取 PDF 所需的子集,而不是一次性下载全部?

javascript - Google map api3 不会在 Chrome 或 IE 中显示

javascript - 如何替换 jQuery $.trim()?

reactjs - 为什么 React 需要 Babel 和 Webpack 才能工作?

javascript - Aurelia Babel 未知选项 base.modules 错误

internet-explorer - Babel 不包括 append 方法?

jquery - Respond.js 和 Modernizr 无法在 IE8 上进行媒体查询

javascript - 不同形式的 Action 取决于按下的按钮

javascript - 简单的登录页面 - 表单方法发布不起作用

ecmascript-6 - 有没有与 ES6 配合良好的代码复杂性计量工具?