always use an IIFE for classes - fixes #435

This commit is contained in:
Sebastian McKenzie
2015-01-10 22:18:30 +11:00
parent 9d4bea70e6
commit 13a52dd300
9 changed files with 118 additions and 111 deletions

View File

@@ -5,16 +5,20 @@ var _prototypeProperties = function (child, staticProps, instanceProps) {
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
};
var Test = function Test() {};
var Test = (function () {
var Test = function Test() {};
_prototypeProperties(Test, null, {
test: {
get: function () {
return 5 + 5;
},
set: function (val) {
this._test = val;
},
enumerable: true
}
});
_prototypeProperties(Test, null, {
test: {
get: function () {
return 5 + 5;
},
set: function (val) {
this._test = val;
},
enumerable: true
}
});
return Test;
})();

View File

@@ -5,13 +5,17 @@ var _prototypeProperties = function (child, staticProps, instanceProps) {
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
};
var Test = function Test() {};
var Test = (function () {
var Test = function Test() {};
_prototypeProperties(Test, null, {
test: {
get: function () {
return 5 + 5;
},
enumerable: true
}
});
_prototypeProperties(Test, null, {
test: {
get: function () {
return 5 + 5;
},
enumerable: true
}
});
return Test;
})();

View File

@@ -1,7 +1,11 @@
"use strict";
var Test = function Test() {};
var Test = (function () {
var Test = function Test() {};
Test.prototype.test = function () {
return 5 + 5;
};
Test.prototype.test = function () {
return 5 + 5;
};
return Test;
})();

View File

@@ -5,13 +5,17 @@ var _prototypeProperties = function (child, staticProps, instanceProps) {
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
};
var Test = function Test() {};
var Test = (function () {
var Test = function Test() {};
_prototypeProperties(Test, null, {
test: {
set: function (val) {
this._test = val;
},
enumerable: true
}
});
_prototypeProperties(Test, null, {
test: {
set: function (val) {
this._test = val;
},
enumerable: true
}
});
return Test;
})();

View File

@@ -5,14 +5,18 @@ var _prototypeProperties = function (child, staticProps, instanceProps) {
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
};
var A = function A() {};
var A = (function () {
var A = function A() {};
A.a = function () {};
A.a = function () {};
_prototypeProperties(A, {
b: {
get: function () {},
set: function (b) {},
enumerable: true
}
});
_prototypeProperties(A, {
b: {
get: function () {},
set: function (b) {},
enumerable: true
}
});
return A;
})();

View File

@@ -14,21 +14,25 @@ var _defineProperty = function (obj, key, value) {
});
};
var Foo = function Foo() {};
var Foo = (function () {
var Foo = function Foo() {};
_prototypeProperties(Foo, null, _defineProperty({
bar: {
_prototypeProperties(Foo, null, _defineProperty({
bar: {
get: function () {
return _defineProperty(this, "bar", complex()).bar;
},
enumerable: true
}
}, bar, {
get: function () {
return _defineProperty(this, "bar", complex()).bar;
return _defineProperty(this, bar, complex())[bar];
},
enumerable: true
}
}, bar, {
get: function () {
return _defineProperty(this, bar, complex())[bar];
},
enumerable: true
}));
}));
return Foo;
})();
var foo = Object.defineProperties({}, _defineProperty({
bar: {

View File

@@ -5,16 +5,20 @@ var _prototypeProperties = function (child, staticProps, instanceProps) {
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
};
var Test = function Test() {};
var Test = (function () {
var Test = function Test() {};
_prototypeProperties(Test, null, {
bar: {
get: function () {
throw new Error("wow");
},
enumerable: true
}
});
_prototypeProperties(Test, null, {
bar: {
get: function () {
throw new Error("wow");
},
enumerable: true
}
});
return Test;
})();
var test = new Test();
test.bar;

View File

@@ -4,7 +4,7 @@
"column": 10
},
"generated": {
"line": 13,
"column": 13
"line": 14,
"column": 15
}
}]