use Object.defineProperty on computed properties - fixes #357

This commit is contained in:
Sebastian McKenzie
2015-01-02 00:36:28 +11:00
parent 7b5b8ab6ed
commit 800c350db6
16 changed files with 197 additions and 82 deletions

View File

@@ -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"));

View File

@@ -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");

View File

@@ -0,0 +1,3 @@
var foo = {
[Symbol.iterator]: "foobar"
};

View File

@@ -0,0 +1,8 @@
"use strict";
var foo = (function () {
var _foo = {};
_foo[Symbol.iterator] = "foobar";
return _foo;
})();

View File

@@ -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";
});

View File

@@ -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"
});
})();

View File

@@ -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;
})({});
})();

View File

@@ -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");

View File

@@ -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");

View File

@@ -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");