我想扩展MediaSource。我在使用Babel。用Babel扩展MediaSource - 如何正确调用super()?
class BradMediaSource extends MediaSource {
constructor() {
super();
}
}
const source = new BradMediaSource();
在Chrome直接,这工作正常。在与巴贝尔做了transpiled构建,我得到以下错误:
Uncaught TypeError: Failed to construct 'MediaSource': Please use the 'new' operator, this DOM object constructor cannot be called as a function.
这似乎与此类似GitHub的问题:https://github.com/babel/babel/issues/1966我也曾尝试以下包,但它似乎并不适用于我的具体情况......没有什么区别:https://www.npmjs.com/package/babel-plugin-transform-custom-element-classes
我.babelrc
:
{ "presets": [ "es2015" ] }
有没有解决这个问题的方法吗?
可能的重复[在ES6中使用Babel扩展内置原生](https://stackoverflow.com/questions/33832646/extending-built-in-natives-in-es6-with-babel) – estus