define class methods instead of assigning them - fixes #454

This commit is contained in:
Sebastian McKenzie
2015-01-12 11:44:23 +11:00
parent d093dc8231
commit 545c8c3adb
8 changed files with 136 additions and 59 deletions

View File

@@ -1,6 +1,11 @@
"use strict";
var _slice = Array.prototype.slice;
var _prototypeProperties = function (child, staticProps, instanceProps) {
if (staticProps) Object.defineProperties(child, staticProps);
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
};
var _get = function get(object, property, receiver) {
var desc = Object.getOwnPropertyDescriptor(object, property);
@@ -54,19 +59,31 @@ var Test = (function (Foo) {
_inherits(Test, Foo);
Test.prototype.test = function () {
var _get6, _get7;
_get(Object.getPrototypeOf(Test.prototype), "test", this).call(this);
(_get6 = _get(Object.getPrototypeOf(Test.prototype), "test", this)).call.apply(_get6, [this].concat(_slice.call(arguments)));
(_get7 = _get(Object.getPrototypeOf(Test.prototype), "test", this)).call.apply(_get7, [this, "test"].concat(_slice.call(arguments)));
};
Test.foo = function () {
var _get8, _get9;
_get(Object.getPrototypeOf(Test), "foo", this).call(this);
(_get8 = _get(Object.getPrototypeOf(Test), "foo", this)).call.apply(_get8, [this].concat(_slice.call(arguments)));
(_get9 = _get(Object.getPrototypeOf(Test), "foo", this)).call.apply(_get9, [this, "test"].concat(_slice.call(arguments)));
};
_prototypeProperties(Test, {
foo: {
value: function () {
var _get6, _get7;
_get(Object.getPrototypeOf(Test), "foo", this).call(this);
(_get6 = _get(Object.getPrototypeOf(Test), "foo", this)).call.apply(_get6, [this].concat(_slice.call(arguments)));
(_get7 = _get(Object.getPrototypeOf(Test), "foo", this)).call.apply(_get7, [this, "test"].concat(_slice.call(arguments)));
},
writable: true,
enumerable: true,
configurable: true
}
}, {
test: {
value: function () {
var _get8, _get9;
_get(Object.getPrototypeOf(Test.prototype), "test", this).call(this);
(_get8 = _get(Object.getPrototypeOf(Test.prototype), "test", this)).call.apply(_get8, [this].concat(_slice.call(arguments)));
(_get9 = _get(Object.getPrototypeOf(Test.prototype), "test", this)).call.apply(_get9, [this, "test"].concat(_slice.call(arguments)));
},
writable: true,
enumerable: true,
configurable: true
}
});
return Test;
})(Foo);

View File

@@ -1,5 +1,10 @@
"use strict";
var _prototypeProperties = function (child, staticProps, instanceProps) {
if (staticProps) Object.defineProperties(child, staticProps);
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
};
var _get = function get(object, property, receiver) {
var desc = Object.getOwnPropertyDescriptor(object, property);
@@ -45,9 +50,16 @@ var Test = (function (Foo) {
_inherits(Test, Foo);
Test.test = function () {
return _get(Object.getPrototypeOf(Test), "wow", this).call(this);
};
_prototypeProperties(Test, {
test: {
value: function () {
return _get(Object.getPrototypeOf(Test), "wow", this).call(this);
},
writable: true,
enumerable: true,
configurable: true
}
});
return Test;
})(Foo);

View File

@@ -1,11 +1,23 @@
"use strict";
var _prototypeProperties = function (child, staticProps, instanceProps) {
if (staticProps) Object.defineProperties(child, staticProps);
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
};
var Test = (function () {
var Test = function Test() {};
Test.prototype.test = function () {
return 5 + 5;
};
_prototypeProperties(Test, null, {
test: {
value: function () {
return 5 + 5;
},
writable: true,
enumerable: true,
configurable: true
}
});
return Test;
})();

View File

@@ -1,5 +1,10 @@
"use strict";
var _prototypeProperties = function (child, staticProps, instanceProps) {
if (staticProps) Object.defineProperties(child, staticProps);
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
};
var BaseView = function BaseView() {
this.autoRender = true;
};
@@ -11,9 +16,16 @@ var BaseView = function () {
var BaseView = (function () {
var _class2 = function () {};
_class2.prototype.foo = function () {
this.autoRender = true;
};
_prototypeProperties(_class2, null, {
foo: {
value: function () {
this.autoRender = true;
},
writable: true,
enumerable: true,
configurable: true
}
});
return _class2;
})();

View File

@@ -8,9 +8,13 @@ var _prototypeProperties = function (child, staticProps, instanceProps) {
var A = (function () {
var A = function A() {};
A.a = function () {};
_prototypeProperties(A, {
a: {
value: function () {},
writable: true,
enumerable: true,
configurable: true
},
b: {
get: function () {},
set: function (b) {},

View File

@@ -1,6 +1,11 @@
"use strict";
var _slice = Array.prototype.slice;
var _prototypeProperties = function (child, staticProps, instanceProps) {
if (staticProps) Object.defineProperties(child, staticProps);
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
};
var _inherits = function (child, parent) {
if (typeof parent !== "function" && parent !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof parent);
@@ -32,19 +37,31 @@ var Test = (function (Foo) {
_inherits(Test, Foo);
Test.prototype.test = function () {
var _Foo$prototype$test3, _Foo$prototype$test4;
Foo.prototype.test.call(this);
(_Foo$prototype$test3 = Foo.prototype.test).call.apply(_Foo$prototype$test3, [this].concat(_slice.call(arguments)));
(_Foo$prototype$test4 = Foo.prototype.test).call.apply(_Foo$prototype$test4, [this, "test"].concat(_slice.call(arguments)));
};
Test.foo = function () {
var _Foo$foo, _Foo$foo2;
Foo.foo.call(this);
(_Foo$foo = Foo.foo).call.apply(_Foo$foo, [this].concat(_slice.call(arguments)));
(_Foo$foo2 = Foo.foo).call.apply(_Foo$foo2, [this, "test"].concat(_slice.call(arguments)));
};
_prototypeProperties(Test, {
foo: {
value: function () {
var _Foo$foo, _Foo$foo2;
Foo.foo.call(this);
(_Foo$foo = Foo.foo).call.apply(_Foo$foo, [this].concat(_slice.call(arguments)));
(_Foo$foo2 = Foo.foo).call.apply(_Foo$foo2, [this, "test"].concat(_slice.call(arguments)));
},
writable: true,
enumerable: true,
configurable: true
}
}, {
test: {
value: function () {
var _Foo$prototype$test3, _Foo$prototype$test4;
Foo.prototype.test.call(this);
(_Foo$prototype$test3 = Foo.prototype.test).call.apply(_Foo$prototype$test3, [this].concat(_slice.call(arguments)));
(_Foo$prototype$test4 = Foo.prototype.test).call.apply(_Foo$prototype$test4, [this, "test"].concat(_slice.call(arguments)));
},
writable: true,
enumerable: true,
configurable: true
}
});
return Test;
})(Foo);

View File

@@ -1,5 +1,10 @@
"use strict";
var _prototypeProperties = function (child, staticProps, instanceProps) {
if (staticProps) Object.defineProperties(child, staticProps);
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
};
var _inherits = function (child, parent) {
if (typeof parent !== "function" && parent !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof parent);
@@ -23,9 +28,16 @@ var Test = (function (Foo) {
_inherits(Test, Foo);
Test.test = function () {
return Foo.wow.call(this);
};
_prototypeProperties(Test, {
test: {
value: function () {
return Foo.wow.call(this);
},
writable: true,
enumerable: true,
configurable: true
}
});
return Test;
})(Foo);