use Object.defineProperty on computed properties - fixes #357
This commit is contained in:
@@ -1,6 +1,12 @@
|
||||
"use strict";
|
||||
|
||||
foo((function (_ref) {
|
||||
_ref[bar] = "foobar";
|
||||
return _ref;
|
||||
})({}));
|
||||
var _defineProperty = function (obj, key, value) {
|
||||
return Object.defineProperty(obj, key, {
|
||||
value: value,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true
|
||||
});
|
||||
};
|
||||
|
||||
foo(_defineProperty({}, bar, "foobar"));
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
"use strict";
|
||||
|
||||
foo = (function (_foo) {
|
||||
_foo[bar] = "foobar";
|
||||
return _foo;
|
||||
})({});
|
||||
var _defineProperty = function (obj, key, value) {
|
||||
return Object.defineProperty(obj, key, {
|
||||
value: value,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true
|
||||
});
|
||||
};
|
||||
|
||||
foo = _defineProperty({}, bar, "foobar");
|
||||
|
||||
3
test/fixtures/transformation/es6-computed-property-names/ignore-symbol/actual.js
vendored
Normal file
3
test/fixtures/transformation/es6-computed-property-names/ignore-symbol/actual.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
var foo = {
|
||||
[Symbol.iterator]: "foobar"
|
||||
};
|
||||
8
test/fixtures/transformation/es6-computed-property-names/ignore-symbol/expected.js
vendored
Normal file
8
test/fixtures/transformation/es6-computed-property-names/ignore-symbol/expected.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
"use strict";
|
||||
|
||||
var foo = (function () {
|
||||
var _foo = {};
|
||||
|
||||
_foo[Symbol.iterator] = "foobar";
|
||||
return _foo;
|
||||
})();
|
||||
@@ -1,9 +1,14 @@
|
||||
"use strict";
|
||||
|
||||
var obj = (function (_obj) {
|
||||
_obj[foobar] = function () {
|
||||
return "foobar";
|
||||
};
|
||||
var _defineProperty = function (obj, key, value) {
|
||||
return Object.defineProperty(obj, key, {
|
||||
value: value,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true
|
||||
});
|
||||
};
|
||||
|
||||
return _obj;
|
||||
})({});
|
||||
var obj = _defineProperty({}, foobar, function () {
|
||||
return "foobar";
|
||||
});
|
||||
|
||||
@@ -1,10 +1,24 @@
|
||||
"use strict";
|
||||
|
||||
var obj = (function (_obj) {
|
||||
_obj["x" + foo] = "heh";
|
||||
_obj["y" + bar] = "noo";
|
||||
var _defineProperty = function (obj, key, value) {
|
||||
return Object.defineProperty(obj, key, {
|
||||
value: value,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true
|
||||
});
|
||||
};
|
||||
|
||||
var obj = (function () {
|
||||
var _obj = {};
|
||||
|
||||
_defineProperty(_obj, "x" + foo, "heh");
|
||||
|
||||
_defineProperty(_obj, "y" + bar, "noo");
|
||||
|
||||
_defineProperty(_obj, "foo", "foo");
|
||||
|
||||
_defineProperty(_obj, "bar", "bar");
|
||||
|
||||
return _obj;
|
||||
})({
|
||||
foo: "foo",
|
||||
bar: "bar"
|
||||
});
|
||||
})();
|
||||
|
||||
@@ -1,7 +1,20 @@
|
||||
"use strict";
|
||||
|
||||
var obj = (function (_obj) {
|
||||
_obj["x" + foo] = "heh";
|
||||
_obj["y" + bar] = "noo";
|
||||
var _defineProperty = function (obj, key, value) {
|
||||
return Object.defineProperty(obj, key, {
|
||||
value: value,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true
|
||||
});
|
||||
};
|
||||
|
||||
var obj = (function () {
|
||||
var _obj = {};
|
||||
|
||||
_defineProperty(_obj, "x" + foo, "heh");
|
||||
|
||||
_defineProperty(_obj, "y" + bar, "noo");
|
||||
|
||||
return _obj;
|
||||
})({});
|
||||
})();
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
"use strict";
|
||||
|
||||
var obj = (function (_obj) {
|
||||
_obj["x" + foo] = "heh";
|
||||
return _obj;
|
||||
})({});
|
||||
var _defineProperty = function (obj, key, value) {
|
||||
return Object.defineProperty(obj, key, {
|
||||
value: value,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true
|
||||
});
|
||||
};
|
||||
|
||||
var obj = _defineProperty({}, "x" + foo, "heh");
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
"use strict";
|
||||
|
||||
var _this = this;
|
||||
var obj = (function (_obj) {
|
||||
_obj["x" + _this.foo] = "heh";
|
||||
return _obj;
|
||||
})({});
|
||||
var _defineProperty = function (obj, key, value) {
|
||||
return Object.defineProperty(obj, key, {
|
||||
value: value,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true
|
||||
});
|
||||
};
|
||||
|
||||
var obj = _defineProperty({}, "x" + this.foo, "heh");
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
"use strict";
|
||||
|
||||
var foo = (function (_foo) {
|
||||
_foo[bar] = "foobar";
|
||||
return _foo;
|
||||
})({});
|
||||
var _defineProperty = function (obj, key, value) {
|
||||
return Object.defineProperty(obj, key, {
|
||||
value: value,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true
|
||||
});
|
||||
};
|
||||
|
||||
var foo = _defineProperty({}, bar, "foobar");
|
||||
|
||||
Reference in New Issue
Block a user