bublejs / bublejs/buble

IE<=10 - "Object does not support method" error when calling a static method extended from a super class

Open
#119 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
874
Forks
62
PR merge metrics
No merged PRs in 30d

Description

Hey there!

I'm trying to use Rollup + Bublé in a project which needs to support older IE browsers. There seems to be some issues in Bublé's transpiled code which causes static inherited methods to be reported as missing.

This is probably because \_\_proto\_\_ is not supported in IE<=10 which causes the static properties to not be inherited.

Babel provides a [transform-proto-to-assign](https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-proto-to-assign) transformation plugin to help with this case. Any way Bublé could add support for a similar transform?

### Bublé version 0.19.3
### ES6 Input
```javascript
// src/a.js
class A {
static fun () {
return 'Static fun!';
}

fun () {
return 'Non-static fun!';
}
}

class B extends A {}

// Non-static invocations
console.log(new A().fun()); // Non-static fun!
console.log(new B().fun()); // Non-static fun!

// Static invocations
console.log(A.fun()); // Static fun!
console.log(B.fun()); // ERROR: Object does not support the property or method fun
```
### Bublé command
```bash
buble src/a.js --target ie:9 -o a-transpiled.js
```
### Bublé Transpiled Output
```javascript
// a-transpiled.js
var A = function A () {};

A.fun = function fun () {
return 'Static fun!';
};

A.prototype.fun = function fun () {
return 'Non-static fun!';
};

var B = (function (A) {
function B () {
A.apply(this, arguments);
}if ( A ) B.__proto__ = A;
B.prototype = Object.create( A && A.prototype );
B.prototype.constructor = B;

return B;
}(A));

// Non-static invocations
console.log(new A().fun()); // Non-static fun!
console.log(new B().fun()); // Non-static fun!

// Static invocations
console.log(A.fun()); // Static fun!
console.log(B.fun()); // ERROR: Object does not support the property or method fun
```
### Expected result
Invoking B.fun() outputs "Static fun!"
### Actual result
Invoking B.fun() results in an error in IE9 and IE10 stating "Object does not support the property or method fun"

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the issue with the provided src/a.js example and the buble src/a.js --target ie:9 -o a-transpiled.js command. Inspect the generated inheritance code and verify the result in IE9 or IE10. Done means the transpiled example allows B.fun() to output "Static fun!" without the reported error.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.