Compare commits

...

27 Commits

Author SHA1 Message Date
Sebastian McKenzie
ca6f8e9a96 v3.3.8 2015-02-04 10:07:50 +11:00
Sebastian McKenzie
55f2cffc22 fix linting errors 2015-02-04 10:05:20 +11:00
Sebastian McKenzie
ca482b79ad add 3.3.8 changelog 2015-02-04 10:04:03 +11:00
Sebastian McKenzie
b1f0ecf244 update class super constructor inheritance tests 2015-02-04 10:03:57 +11:00
Sebastian McKenzie
36fa174901 change instance reference to this in class super constructor call template - fixes #689 2015-02-04 10:03:15 +11:00
Sebastian McKenzie
e8dc4628ae better handle spaces in IfStatement generator 2015-02-04 08:40:23 +11:00
Sebastian McKenzie
7a0dbb0203 fix node removal 2015-02-04 08:39:54 +11:00
Sebastian McKenzie
8d81a382f7 inline back the super constructor call helper - fixes #684 2015-02-04 08:39:45 +11:00
Sebastian McKenzie
86fbba08d8 add concise format option 2015-02-04 08:39:17 +11:00
Sebastian McKenzie
23c6e7e168 fix incorrect getThisReference bind - fixes #688 2015-02-04 08:26:18 +11:00
Sebastian McKenzie
c35f041091 simplify to.isFalsyExpression method 2015-02-04 08:25:40 +11:00
Sebastian McKenzie
618c6a8e67 add isLiteral to inferType 2015-02-04 08:25:15 +11:00
Sebastian McKenzie
23429f7b7f remove blank optimization 2015-02-04 08:25:00 +11:00
Sebastian McKenzie
d6052b483a add 6to5-minify to package.json 2015-02-04 08:24:53 +11:00
Sebastian McKenzie
3b3255a964 delegate removal of nodes in traversal to exitNode 2015-02-04 08:24:38 +11:00
Sebastian McKenzie
49847e70af add some minification transformers 2015-02-04 08:23:58 +11:00
Sebastian McKenzie
c228d76e44 add 6to5-minify 2015-02-04 08:23:49 +11:00
Sebastian McKenzie
6da6bc3eb8 remove callExpression type inferrence 2015-02-03 22:32:00 +11:00
Sebastian McKenzie
bbcfc3c9f2 3.3.7 2015-02-03 22:29:09 +11:00
Sebastian McKenzie
12b1de7c9d v3.3.7 2015-02-03 22:27:37 +11:00
Sebastian McKenzie
721636f475 add 3.3.7 changelog 2015-02-03 22:25:33 +11:00
Sebastian McKenzie
4c94941ceb force .js extension when writing files to directories with 6to5 2015-02-03 22:25:27 +11:00
Sebastian McKenzie
f06535e915 rename Scope.init to Scope.crawl 2015-02-03 22:22:36 +11:00
Sebastian McKenzie
389914c427 add use-strict to valid node flags - fixes #667 2015-02-03 22:21:55 +11:00
Sebastian McKenzie
c7f5715d8e fix boolean stripping from 6to5-node - fixes #679 2015-02-03 22:21:09 +11:00
Sebastian McKenzie
29f866525e clean up scope tracking and add some simple flow type tracking and inferrence #653 2015-02-03 21:06:21 +11:00
Sebastian McKenzie
de61455a55 3.3.5 2015-02-03 21:05:36 +11:00
29 changed files with 365 additions and 143 deletions

View File

@@ -11,6 +11,19 @@
_Note: Gaps between patch versions are faulty/broken releases._
## 3.3.8
* **Bug Fix**
* Fix super inside of functions.
* Fix super constructor inheritance.
## 3.3.7
* **Bug Fix**
* Add `--use-strict` to valid node flags in `6to5-node`.
* Fix booleans not being properly stripped from the arguments in `6to5-node`.
* Force `.js` extension when writing files to directories with `6to5`.
## 3.3.5
* **Bug Fix**

7
bin/6to5-minify Executable file
View File

@@ -0,0 +1,7 @@
#!/usr/bin/env node
var opts = require("./6to5").opts;
opts.optional = (opts.optional || []).concat("minification");
opts.format = {
compact: true
};

View File

@@ -35,6 +35,7 @@ process.argv.slice(2).forEach(function(arg){
case "--prof":
case "--throw-deprecation":
case "--trace-deprecation":
case "--use-strict":
args.unshift(arg);
break;

View File

@@ -11,6 +11,9 @@ module.exports = function (commander, filenames, opts) {
}
var write = function (src, relative) {
// remove extension and then append back on .js
relative = relative.replace(/\.(\w*?)$/, "") + ".js";
var dest = path.join(commander.outDir, relative);
var data = util.compile(src, { sourceMapName: dest });

View File

@@ -114,12 +114,17 @@ exports.opts = {
loose: commander.loose
};
var fn;
setTimeout(function () {
// this is just a hack to give `6to5-minify` and other files including this
// time to modify `exports.opts`
if (commander.outDir) {
fn = require("./dir");
} else {
fn = require("./file");
}
var fn;
fn(commander, filenames, exports.opts);
if (commander.outDir) {
fn = require("./dir");
} else {
fn = require("./file");
}
fn(commander, filenames, exports.opts);
}, 0);

View File

@@ -72,7 +72,8 @@ if (program.eval || program.print) {
}
if (arg[0] === "-") {
if (program[arg.slice(2)]) {
var parsedArg = program[arg.slice(2)];
if (parsedArg && parsedArg !== true) {
ignoreNext = true;
}
} else {

View File

@@ -19,7 +19,7 @@ Buffer.prototype.get = function () {
};
Buffer.prototype.getIndent = function () {
if (this.format.compact) {
if (this.format.compact || this.format.concise) {
return "";
} else {
return util.repeat(this._indent, this.format.indent.style);
@@ -53,10 +53,12 @@ Buffer.prototype.rightBrace = function () {
Buffer.prototype.keyword = function (name) {
this.push(name);
this.push(" ");
this.space();
};
Buffer.prototype.space = function () {
if (this.format.compact) return;
if (this.buf && !this.isLast([" ", "\n"])) {
this.push(" ");
}
@@ -70,7 +72,7 @@ Buffer.prototype.removeLast = function (cha) {
};
Buffer.prototype.newline = function (i, removeLast) {
if (this.format.compact) {
if (this.format.compact || this.format.concise) {
this.space();
return;
}

View File

@@ -17,7 +17,7 @@ exports.UnaryExpression = function (node, print) {
}
this.push(node.operator);
if (hasSpace) this.space();
if (hasSpace) this.push(" ");
print(node.argument);
};
@@ -33,9 +33,13 @@ exports.UpdateExpression = function (node, print) {
exports.ConditionalExpression = function (node, print) {
print(node.test);
this.push(" ? ");
this.space();
this.push("?");
this.space();
print(node.consequent);
this.push(" : ");
this.space();
this.push(":");
this.space();
print(node.alternate);
};
@@ -44,13 +48,13 @@ exports.NewExpression = function (node, print) {
print(node.callee);
if (node.arguments.length || this.format.parentheses) {
this.push("(");
print.join(node.arguments, { separator: ", " });
print.list(node.arguments);
this.push(")");
}
};
exports.SequenceExpression = function (node, print) {
print.join(node.expressions, { separator: ", " });
print.list(node.expressions);
};
exports.ThisExpression = function () {
@@ -72,9 +76,7 @@ exports.CallExpression = function (node, print) {
separator += " ";
}
print.join(node.arguments, {
separator: separator
});
print.list(node.arguments, { separator: separator });
if (node._prettyCall) {
this.newline();
@@ -115,10 +117,11 @@ exports.BinaryExpression =
exports.LogicalExpression =
exports.AssignmentPattern =
exports.AssignmentExpression = function (node, print) {
// todo: add cases where the spaces can be dropped when in compact mode
print(node.left);
this.space();
this.push(" ");
this.push(node.operator);
this.space();
this.push(" ");
print(node.right);
};

View File

@@ -4,11 +4,7 @@ var t = require("../../types");
exports._params = function (node, print) {
this.push("(");
print.join(node.params, {
separator: ", "
});
print.list(node.params);
this.push(")");
};
@@ -45,11 +41,14 @@ exports.FunctionExpression = function (node, print) {
if (node.async) this.push("async ");
this.push("function");
if (node.generator) this.push("*");
this.push(" ");
if (node.id) {
this.space();
this.push(" ");
print(node.id);
} else {
this.space();
}
this._params(node, print);
this.space();
print(node.body);

View File

@@ -23,6 +23,11 @@ exports.IfStatement = function (node, print) {
if (node.alternate) {
if (this.isLast("}")) this.push(" ");
this.keyword("else");
if (this.format.format && !t.isBlockStatement(node.alternate)) {
this.push(" ");
}
print.indentOnComments(node.alternate);
}
};
@@ -190,7 +195,7 @@ exports.VariableDeclaration = function (node, print, parent) {
sep += " ";
}
print.join(node.declarations, { separator: sep });
print.list(node.declarations, { separator: sep });
if (!t.isFor(parent)) {
this.semicolon();

View File

@@ -27,7 +27,7 @@ exports.ObjectPattern = function (node, print) {
this.push("{");
this.space();
print.join(props, { separator: ", ", indent: true });
print.list(props, { indent: true });
this.space();
this.push("}");
@@ -49,7 +49,8 @@ exports.Property = function (node, print) {
if (node.shorthand) return;
}
this.push(": ");
this.push(":");
this.space();
print(node.value);
}
};
@@ -71,7 +72,7 @@ exports.ArrayPattern = function (node, print) {
// both (all) of the holes.
self.push(",");
} else {
if (i > 0) self.push(" ");
if (i > 0 && !self.format.compact) self.push(" ");
print(elem);
if (i < len - 1) self.push(",");
}

View File

@@ -50,6 +50,7 @@ CodeGenerator.normalizeOptions = function (code, opts) {
parentheses: true,
comments: opts.comments == null || opts.comments,
compact: false,
concise: false,
indent: {
adjustMultilineComment: true,
style: style,
@@ -111,6 +112,16 @@ CodeGenerator.prototype.buildPrint = function (parent) {
return self.printJoin(print, nodes, opts);
};
print.list = function (items, opts) {
opts = opts || {};
var sep = opts.separator || ", ";
if (self.format.compact) sep = ",";
opts.separator = sep;
print.join(items, opts);
};
print.block = function (node) {
return self.printBlock(print, node);
};
@@ -129,9 +140,9 @@ CodeGenerator.prototype.print = function (node, parent, opts) {
node._compact = true;
}
var oldCompact = this.format.compact;
var oldConcise = this.format.concise;
if (node._compact) {
this.format.compact = true;
this.format.concise = true;
}
var self = this;
@@ -198,7 +209,7 @@ CodeGenerator.prototype.print = function (node, parent, opts) {
throw new ReferenceError("unknown node of type " + JSON.stringify(node.type) + " with constructor " + JSON.stringify(node && node.constructor.name));
}
this.format.compact = oldCompact;
this.format.concise = oldConcise;
};
CodeGenerator.prototype.printJoin = function (print, nodes, opts) {

View File

@@ -150,7 +150,7 @@ var visitor = {
// top level so `this` is the instance
t.thisExpression :
// not in the top level so we need to create a reference
self.getThisReference;
self.getThisReference.bind(self);
var callback = self.specHandle;
if (self.isLoose) callback = self.looseHandle;

View File

@@ -1,5 +1,3 @@
(function (instance, Constructor) {
if (Object.getPrototypeOf(Constructor) !== null) {
Object.getPrototypeOf(Constructor).apply(instance, arguments);
}
});
if (Object.getPrototypeOf(CLASS_NAME) !== null) {
Object.getPrototypeOf(CLASS_NAME).apply(this, arguments);
}

View File

@@ -169,19 +169,11 @@ Class.prototype.buildBody = function () {
// we have no constructor, we have a super, and the super doesn't appear to be falsy
if (!this.hasConstructor && superName && !t.isFalsyExpression(superName)) {
var helperName = "class-super-constructor-call";
if (this.isLoose) {
constructor.body.body.push(util.template(helperName + "-loose", {
CLASS_NAME: className,
SUPER_NAME: this.superName
}, true));
} else {
constructor.body.body.push(
t.expressionStatement(
t.callExpression(this.file.addHelper(helperName), [t.thisExpression(), className])
)
);
}
if (this.isLoose) helperName += "-loose";
constructor.body.body.push(util.template(helperName, {
CLASS_NAME: className,
SUPER_NAME: this.superName
}, true));
}
var instanceProps;

View File

@@ -80,5 +80,10 @@ module.exports = {
"spec.undefinedToVoid": require("./spec/undefined-to-void"),
"minification.propertyLiterals": require("./minification/property-literals"),
"minification.memberExpressionLiterals": require("./minification/member-expression-literals")
"minification.memberExpressionLiterals": require("./minification/member-expression-literals"),
"minification.removeDebugger": require("./minification/remove-debugger"),
"minification.removeConsoleCalls": require("./minification/remove-console-calls"),
"minification.deadCodeElimination": require("./minification/dead-code-elimination"),
"minification.renameLocalVariables": require("./minification/rename-local-variables")
};

View File

@@ -0,0 +1,77 @@
var t = require("../../../types");
exports.optional = true;
exports.ExpressionStatement = function (node, parent, scope, context) {
// remove consequenceless expressions such as local variables and literals
//
// var foo = true; foo; -> var foo = true;
// "foo"; ->
//
var expr = node.expression;
if (t.isLiteral(expr) || (t.isIdentifier(node) && t.hasBinding(node.name))) {
context.remove();
}
};
exports.IfStatement = {
exit: function (node, parent, scope, context) {
// todo: in scenarios where we can just return the consequent or
// alternate we should drop the block statement if it contains no
// block scoped variables
var consequent = node.consequent;
var alternate = node.alternate;
var test = node.test;
// we can check if a test will be truthy 100% and if so we can inline
// the consequent and completely ignore the alternate
//
// if (true) { foo; } -> { foo; }
// if ("foo") { foo; } -> { foo; }
//
if (t.isLiteral(test) && test.value) {
return alternate;
}
// we can check if a test will be falsy 100% and if so we can inline
// the alternate if there is one and completely remove the consequent
//
// if ("") { bar; } else { foo; } -> { foo; }
// if ("") { bar; } ->
//
if (t.isFalsyExpression(test)) {
if (alternate) {
return alternate;
} else {
return context.remove();
}
}
// remove alternate blocks that are empty
//
// if (foo) { foo; } else {} -> if (foo) { foo; }
//
if (t.isBlockStatement(alternate) && !alternate.body.length) {
alternate = node.alternate = null;
}
// turn alternate blocks into a consequent and flip the test if the
// consequent block is empty
//
// if (foo) {} else { bar; }
// if (!foo) { bar; }
//
if (t.blockStatement(consequent) && !consequent.body.length &&
t.isBlockStatement(alternate) && alternate.body.length) {
node.consequent = node.alternate;
node.alternate = null;
node.test = t.unaryExpression("!", test, true);
}
}
};

View File

@@ -0,0 +1,13 @@
"use strict";
var t = require("../../../types");
var isConsole = t.buildMatchMemberExpression("console", true);
exports.optional = true;
exports.CallExpression = function (node, parent, scope, context) {
if (isConsole(node.callee)) {
context.remove();
}
};

View File

@@ -0,0 +1,9 @@
var t = require("../../../types");
exports.optional = true;
exports.ExpressionStatement = function (node, parent, scope, context) {
if (t.isIdentifier(node.expression, { name: "debugger" })) {
context.remove();
}
};

View File

@@ -0,0 +1,10 @@
//var t = require("../../../types");
exports.optional = true;
exports.Scope = function () {
// todo: get all binding identifiers, generate compact names
// that wont collide and then call the remap identifier helper
// this transformer **has** to be ran last as it will absolutley
// destroy the scope tree
};

View File

@@ -41,6 +41,13 @@ TraversalContext.prototype.reset = function () {
this.shouldStop = false;
};
TraversalContext.prototype.maybeRemove = function (obj, key) {
if (this.shouldRemove) {
obj[key] = null;
this.shouldFlatten = true;
}
};
function replaceNode(obj, key, node, result) {
var isArray = Array.isArray(result);
@@ -76,10 +83,7 @@ TraversalContext.prototype.enterNode = function (obj, key, node, enter, parent,
}
}
if (this.shouldRemove) {
obj[key] = null;
this.shouldFlatten = true;
}
this.maybeRemove(obj, key);
return node;
};
@@ -97,6 +101,8 @@ TraversalContext.prototype.exitNode = function (obj, key, node, exit, parent, sc
}
}
this.maybeRemove(obj, key);
return node;
};

View File

@@ -30,11 +30,7 @@ function Scope(block, parentBlock, parent, file) {
this.parentBlock = parentBlock;
this.block = block;
var info = this.getInfo();
this.references = info.references;
this.bindings = info.bindings;
this.declarationKinds = info.declarationKinds;
this.crawl();
}
Scope.defaultDeclarations = flatten([globals.builtin, globals.browser, globals.node].map(Object.keys));
@@ -126,12 +122,91 @@ Scope.prototype.generateTempBasedOnNode = function (node) {
return id;
};
Scope.prototype.checkBlockScopedCollisions = function (key, id) {
if (this.declarationKinds["let"][key] || this.declarationKinds["const"][key]) {
throw this.file.errorWithNode(id, "Duplicate declaration " + key, TypeError);
}
};
Scope.prototype.inferType = function (node) {
var target;
if (t.isVariableDeclarator(node)) {
target = node.init;
}
if (t.isLiteral(target) || t.isArrayExpression(target) || t.isObjectExpression(target)) {
// todo: possibly call some helper that will resolve these to a type annotation
}
if (t.isCallExpression(target)) {
// todo: need to resolve this to a return type
}
if (t.isMemberExpression(target)) {
// todo: crawl this and find the correct type, bail on anything that we cannot
// possibly be 100% confident on
}
if (t.isIdentifier(target)) {
return this.getType(target.name);
}
};
Scope.prototype.registerType = function (key, id, node) {
var type;
if (id.typeAnnotation) {
type = id.typeAnnotation;
}
if (!type) {
type = this.inferType(node);
}
if (type) {
if (t.isTypeAnnotation(type)) type = type.typeAnnotation;
this.types[key] = type;
}
};
Scope.prototype.register = function (node, reference, kind) {
if (t.isVariableDeclaration(node)) {
return this.registerVariableDeclaration(node);
}
var ids = t.getBindingIdentifiers(node);
extend(this.references, ids);
if (reference) return;
for (var key in ids) {
var id = ids[key];
this.checkBlockScopedCollisions(key, id);
this.registerType(key, id, node);
this.bindings[key] = id;
}
var kinds = this.declarationKinds[kind];
if (kinds) extend(kinds, ids);
};
Scope.prototype.registerVariableDeclaration = function (declar) {
var declars = declar.declarations;
for (var i = 0; i < declars.length; i++) {
this.register(declars[i], false, declar.kind);
}
};
var functionVariableVisitor = {
enter: function (node, parent, scope, context, state) {
if (t.isFor(node)) {
each(t.FOR_INIT_KEYS, function (key) {
var declar = node[key];
if (t.isVar(declar)) state.add(declar);
if (t.isVar(declar)) state.scope.register(declar);
});
}
@@ -149,82 +224,69 @@ var functionVariableVisitor = {
if (t.isExportDeclaration(node) && t.isDeclaration(node.declaration)) return;
// we've ran into a declaration!
if (t.isDeclaration(node)) state.add(node);
if (t.isDeclaration(node)) state.scope.register(node);
}
};
var programReferenceVisitor = {
enter: function (node, parent, scope, context, add) {
enter: function (node, parent, scope, context, state) {
if (t.isReferencedIdentifier(node, parent) && !scope.hasReference(node.name)) {
add(node, true);
state.register(node, true);
}
}
};
var blockVariableVisitor = {
enter: function (node, parent, scope, context, add) {
enter: function (node, parent, scope, context, state) {
if (t.isBlockScoped(node)) {
add(node, false);
state.register(node);
} else if (t.isScope(node)) {
context.skip();
}
}
};
Scope.prototype.getInfo = function () {
Scope.prototype.crawl = function () {
var parent = this.parent;
var block = this.block;
var self = this;
if (block._scopeInfo) return block._scopeInfo;
var i;
var info = block._scopeInfo = {};
//
var bindings = info.bindings = object();
var references = info.references = object();
var types = info.types = object();
var declarationKinds = info.declarationKinds = {
"const": object(),
"var": object(),
"let": object()
var info = block._scopeInfo;
if (info) {
extend(this, info);
return;
}
info = block._scopeInfo = {
declarationKinds: {
"const": object(),
"var": object(),
"let": object()
},
references: object(),
bindings: object(),
types: object(),
};
var add = function (node, reference) {
var ids = t.getBindingIdentifiers(node);
extend(this, info);
extend(references, ids);
if (!reference) {
for (var key in ids) {
var id = ids[key];
if (id.typeAnnotation) {
types[id] = id.typeAnnotation;
}
if (declarationKinds["let"][key] || declarationKinds["const"][key]) {
throw self.file.errorWithNode(id, "Duplicate declaration " + key, TypeError);
}
}
extend(bindings, ids);
var kinds = declarationKinds[node.kind];
if (kinds) extend(kinds, ids);
}
};
//
if (parent && t.isBlockStatement(block) && t.isLoop(parent.block, { body: block })) {
// delegate let bindings to the parent loop
return info;
return;
}
// ForStatement - left, init
if (t.isLoop(block)) {
each(t.FOR_INIT_KEYS, function (key) {
var node = block[key];
if (t.isBlockScoped(node)) add(node, false, true);
});
for (i = 0; i < t.FOR_INIT_KEYS.length; i++) {
var node = block[t.FOR_INIT_KEYS[i]];
if (t.isBlockScoped(node)) this.register(node, false, true);
}
if (t.isBlockStatement(block.body)) {
block = block.body;
@@ -234,19 +296,27 @@ Scope.prototype.getInfo = function () {
// Program, BlockStatement - let variables
if (t.isBlockStatement(block) || t.isProgram(block)) {
traverse(block, blockVariableVisitor, this, add);
traverse(block, blockVariableVisitor, this, this);
}
// CatchClause - param
if (t.isCatchClause(block)) {
add(block.param);
this.register(block.param);
}
// ComprehensionExpression - blocks
if (t.isComprehensionExpression(block)) {
add(block);
this.register(block);
}
// Function - params, rest
if (t.isFunction(block)) {
for (i = 0; i < block.params.length; i++) {
this.register(block.params[i]);
}
}
// Program, Function - var variables
@@ -254,7 +324,7 @@ Scope.prototype.getInfo = function () {
if (t.isProgram(block) || t.isFunction(block)) {
traverse(block, functionVariableVisitor, this, {
blockId: block.id,
add: add
scope: this
});
}
@@ -262,25 +332,15 @@ Scope.prototype.getInfo = function () {
if (!t.isProperty(this.parentBlock, { method: true })) {
// SpiderMonkey AST doesn't use MethodDefinition here when it probably
// should since they should be semantically the same?
add(block.id);
this.register(block.id);
}
}
// Program
if (t.isProgram(block)) {
traverse(block, programReferenceVisitor, this, add);
traverse(block, programReferenceVisitor, this, this);
}
// Function - params, rest
if (t.isFunction(block)) {
each(block.params, function (param) {
add(param);
});
}
return info;
};
/**

View File

@@ -127,9 +127,7 @@ t.toComputedKey = function (node, key) {
};
/*
* Shallowly checks to see if the passed `node` will evaluate to a
* falsy. This is if `node` is a `Literal` and `value` is falsy or
* `node` is an `Identifier` with a name of `undefiend`.
* Shallowly checks to see if the passed `node` is falsy.
*
* @param {Object} node
* @returns {Boolean}

View File

@@ -1,7 +1,7 @@
{
"name": "6to5",
"description": "Turn ES6 code into readable vanilla ES5 with source maps",
"version": "3.3.5",
"version": "3.3.8",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://6to5.org/",
"repository": "6to5/6to5",
@@ -9,6 +9,7 @@
"main": "lib/6to5/index.js",
"bin": {
"6to5": "./bin/6to5/index.js",
"6to5-minify": "./bin/6to5-minify",
"6to5-node": "./bin/6to5-node",
"6to5-runtime": "./bin/6to5-runtime"
},

View File

@@ -1,7 +1,7 @@
{
"name": "6to5-runtime",
"description": "6to5 selfContained runtime",
"version": "3.3.4",
"version": "3.3.7",
"repository": "6to5/6to5",
"author": "Sebastian McKenzie <sebmck@gmail.com>"
}

View File

@@ -1,7 +1,5 @@
"use strict";
var _classSuperConstructorCall = function (instance, Constructor) { if (Object.getPrototypeOf(Constructor) !== null) { Object.getPrototypeOf(Constructor).apply(instance, arguments); } };
var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
@@ -10,7 +8,9 @@ var BaseController = (function (_Chaplin$Controller) {
function BaseController() {
_classCallCheck(this, BaseController);
_classSuperConstructorCall(this, BaseController);
if (Object.getPrototypeOf(BaseController) !== null) {
Object.getPrototypeOf(BaseController).apply(this, arguments);
}
}
_inherits(BaseController, _Chaplin$Controller);
@@ -22,10 +22,12 @@ var BaseController2 = (function (_Chaplin$Controller$Another) {
function BaseController2() {
_classCallCheck(this, BaseController2);
_classSuperConstructorCall(this, BaseController2);
if (Object.getPrototypeOf(BaseController2) !== null) {
Object.getPrototypeOf(BaseController2).apply(this, arguments);
}
}
_inherits(BaseController2, _Chaplin$Controller$Another);
return BaseController2;
})(Chaplin.Controller.Another);
})(Chaplin.Controller.Another);

View File

@@ -1,7 +1,5 @@
"use strict";
var _classSuperConstructorCall = function (instance, Constructor) { if (Object.getPrototypeOf(Constructor) !== null) { Object.getPrototypeOf(Constructor).apply(instance, arguments); } };
var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
@@ -10,10 +8,12 @@ var Test = (function (Foo) {
function Test() {
_classCallCheck(this, Test);
_classSuperConstructorCall(this, Test);
if (Object.getPrototypeOf(Test) !== null) {
Object.getPrototypeOf(Test).apply(this, arguments);
}
}
_inherits(Test, Foo);
return Test;
})(Foo);
})(Foo);

View File

@@ -2,8 +2,6 @@
var _defaults = function (obj, defaults) { for (var key in defaults) { if (obj[key] === undefined) { obj[key] = defaults[key]; } } return obj; };
var _classSuperConstructorCall = function (instance, Constructor) { if (Object.getPrototypeOf(Constructor) !== null) { Object.getPrototypeOf(Constructor).apply(instance, arguments); } };
var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) _defaults(subClass, superClass); };
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
@@ -12,10 +10,12 @@ var Foo = (function (Bar) {
function Foo() {
_classCallCheck(this, Foo);
_classSuperConstructorCall(this, Foo);
if (Object.getPrototypeOf(Foo) !== null) {
Object.getPrototypeOf(Foo).apply(this, arguments);
}
}
_inherits(Foo, Bar);
return Foo;
})(Bar);
})(Bar);