fix computed accessors on objects
This commit is contained in:
8
test/fixtures/transformation/es6-property-method-assignment/computed/actual.js
vendored
Normal file
8
test/fixtures/transformation/es6-property-method-assignment/computed/actual.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
var x = "y";
|
||||
var valueSet;
|
||||
var obj = {
|
||||
get [x] () { return 1 },
|
||||
set [x] (value) { valueSet = value }
|
||||
};
|
||||
obj.y = "foo";
|
||||
obj.y === 1 && valueSet === "foo";
|
||||
24
test/fixtures/transformation/es6-property-method-assignment/computed/expected.js
vendored
Normal file
24
test/fixtures/transformation/es6-property-method-assignment/computed/expected.js
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
"use strict";
|
||||
|
||||
var _defineProperty = function (obj, key, value) {
|
||||
return Object.defineProperty(obj, key, {
|
||||
value: value,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true
|
||||
});
|
||||
};
|
||||
|
||||
var x = "y";
|
||||
var valueSet;
|
||||
var obj = Object.defineProperties({}, _defineProperty({}, x, {
|
||||
get: function () {
|
||||
return 1;
|
||||
},
|
||||
set: function (value) {
|
||||
valueSet = value;
|
||||
},
|
||||
enumerable: true
|
||||
}));
|
||||
obj.y = "foo";
|
||||
obj.y === 1 && valueSet === "foo";
|
||||
@@ -30,13 +30,16 @@ _prototypeProperties(Foo, null, _defineProperty({
|
||||
enumerable: true
|
||||
}));
|
||||
|
||||
var foo = _defineProperty(Object.defineProperties({}, {
|
||||
var foo = Object.defineProperties({}, _defineProperty({
|
||||
bar: {
|
||||
get: function () {
|
||||
return _defineProperty(this, "bar", complex()).bar;
|
||||
},
|
||||
enumerable: true
|
||||
}
|
||||
}), bar, function () {
|
||||
return _defineProperty(this, bar, complex())[bar];
|
||||
});
|
||||
}, bar, {
|
||||
get: function () {
|
||||
return _defineProperty(this, bar, complex())[bar];
|
||||
},
|
||||
enumerable: true
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user