Justin Ridgewell 8f24f91166
Implement MemberExpressionToFunctions helper (#7763)
* Implement MemberExpressionToFunctions helper

Fixes #7733.

This will also be used to simplify the Private Fields transform, which had [almost the same code](ccd941057a/packages/babel-plugin-proposal-class-properties/src/index.js (L114-L217)) hand written.

* Cleanup

* Little more comment cleanup

* Use unary plus

This can't be redefined, unlike the `Number` identifier.

* Review comments

* Remove unused deps
2018-04-21 13:13:42 -04:00

15 lines
359 B
JavaScript

var _obj;
var Base = {
test: '1'
};
var obj = _obj = {
bar: function () {
return babelHelpers.set(babelHelpers.getPrototypeOf(_obj), "test", +babelHelpers.get(babelHelpers.getPrototypeOf(_obj), "test", this) + 1, this, false);
}
};
Object.setPrototypeOf(obj, Base);
expect(obj.bar()).toBe(2);
expect(Base.test).toBe('1');
expect(obj.test).toBe(2);