Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ClassA
- {
- this.alpha = 3;
- }
- class ClassB extends ClassA
- {
- this.beta = 42;
- }
- // === after running Closure Compiler becomes
- function ClassA()
- {
- this.alpha = 3;
- }
- function ClassB()
- {
- ClassA.call(this);
- this.beta = 42;
- }
- q(ClassB, ClassA); // <<<<<<<<
- // === original definition of q() - basically polyfills Object.create and Object.setPrototypeOf
- var e = 'function' == typeof Object.create ? Object.create : function(b) {
- function a() {
- }
- a.prototype = b;
- return new a;
- }, f;
- if ('function' == typeof Object.setPrototypeOf) {
- f = Object.setPrototypeOf;
- } else {
- var h;
- a: {
- var k = {s:!0}, m = {};
- try {
- m.__proto__ = k;
- h = m.s;
- break a;
- } catch (b) {
- }
- h = !1;
- }
- f = h ? function(b, a) {
- b.__proto__ = a;
- if (b.__proto__ !== a) {
- throw new TypeError(b + ' is not extensible');
- }
- return b;
- } : null;
- }
- var n = f;
- function q(b, a) {
- b.prototype = e(a.prototype);
- b.prototype.constructor = b;
- if (n) {
- n(b, a);
- } else {
- for (var d in a) {
- if ('prototype' != d) {
- if (Object.defineProperties) {
- var c = Object.getOwnPropertyDescriptor(a, d);
- c && Object.defineProperty(b, d, c);
- } else {
- b[d] = a[d];
- }
- }
- }
- }
- b.F = a.prototype;
- }
- // === simplified
- var e = Object.create, f = Object.setPrototypeOf, n = f;
- function q(b, a) {
- b.prototype = e(a.prototype);
- b.prototype.constructor = b;
- if (n) {
- n(b, a);
- } else {
- for (var d in a) {
- if ('prototype' != d) {
- if (Object.defineProperties) {
- var c = Object.getOwnPropertyDescriptor(a, d);
- c && Object.defineProperty(b, d, c);
- } else {
- b[d] = a[d];
- }
- }
- }
- }
- b.F = a.prototype;
- }
- // === simplified again
- var e = Object.create, f = Object.setPrototypeOf, n = f;
- function q(b, a) {
- b.prototype = e(a.prototype);
- b.prototype.constructor = b;
- n(b, a);
- b.F = a.prototype;
- }
- // === and again
- function q(b, a) {
- b.prototype = Object.create(a.prototype);
- b.prototype.constructor = b;
- Object.setPrototypeOf(b, a);
- b.F = a.prototype;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement