Adds ES5 to ES3 transformer for reserved words

This commit is contained in:
Ron Buckton 2016-10-13 17:53:44 -07:00
parent 994dae70f0
commit c4300e017f
50 changed files with 270 additions and 208 deletions

View file

@ -70,13 +70,14 @@ var compilerSources = [
"visitor.ts",
"transformers/destructuring.ts",
"transformers/ts.ts",
"transformers/jsx.ts",
"transformers/es7.ts",
"transformers/es6.ts",
"transformers/es5.ts",
"transformers/generators.ts",
"transformers/module/es6.ts",
"transformers/module/system.ts",
"transformers/module/module.ts",
"transformers/jsx.ts",
"transformers/es7.ts",
"transformers/generators.ts",
"transformers/es6.ts",
"transformer.ts",
"sourcemap.ts",
"comments.ts",
@ -104,13 +105,14 @@ var servicesSources = [
"visitor.ts",
"transformers/destructuring.ts",
"transformers/ts.ts",
"transformers/jsx.ts",
"transformers/es7.ts",
"transformers/es6.ts",
"transformers/es5.ts",
"transformers/generators.ts",
"transformers/module/es6.ts",
"transformers/module/system.ts",
"transformers/module/module.ts",
"transformers/jsx.ts",
"transformers/es7.ts",
"transformers/generators.ts",
"transformers/es6.ts",
"transformer.ts",
"sourcemap.ts",
"comments.ts",

View file

@ -3,6 +3,7 @@
/// <reference path="transformers/jsx.ts" />
/// <reference path="transformers/es7.ts" />
/// <reference path="transformers/es6.ts" />
/// <reference path="transformers/es5.ts" />
/// <reference path="transformers/generators.ts" />
/// <reference path="transformers/module/module.ts" />
/// <reference path="transformers/module/system.ts" />
@ -122,6 +123,10 @@ namespace ts {
transformers.push(transformGenerators);
}
if (languageVersion < ScriptTarget.ES5) {
transformers.push(transformES5);
}
return transformers;
}

View file

@ -0,0 +1,83 @@
/// <reference path="../factory.ts" />
/// <reference path="../visitor.ts" />
/*@internal*/
namespace ts {
/**
* Transforms ES5 syntax into ES3 syntax.
*
* @param context Context and state information for the transformation.
*/
export function transformES5(context: TransformationContext) {
const previousOnSubstituteNode = context.onSubstituteNode;
context.onSubstituteNode = onSubstituteNode;
context.enableSubstitution(SyntaxKind.PropertyAccessExpression);
context.enableSubstitution(SyntaxKind.PropertyAssignment);
return transformSourceFile;
/**
* Transforms an ES5 source file to ES3.
*
* @param node A SourceFile
*/
function transformSourceFile(node: SourceFile) {
return node;
}
/**
* Hooks node substitutions.
*
* @param emitContext The context for the emitter.
* @param node The node to substitute.
*/
function onSubstituteNode(emitContext: EmitContext, node: Node) {
node = previousOnSubstituteNode(emitContext, node);
if (isPropertyAccessExpression(node)) {
return substitutePropertyAccessExpression(node);
}
else if (isPropertyAssignment(node)) {
return substitutePropertyAssignment(node);
}
return node;
}
/**
* Substitutes a PropertyAccessExpression whose name is a reserved word.
*
* @param node A PropertyAccessExpression
*/
function substitutePropertyAccessExpression(node: PropertyAccessExpression): Expression {
const literalName = trySubstituteReservedName(node.name);
if (literalName) {
return createElementAccess(node.expression, literalName, /*location*/ node);
}
return node;
}
/**
* Substitutes a PropertyAssignment whose name is a reserved word.
*
* @param node A PropertyAssignment
*/
function substitutePropertyAssignment(node: PropertyAssignment): PropertyAssignment {
const literalName = isIdentifier(node.name) && trySubstituteReservedName(node.name);
if (literalName) {
return updatePropertyAssignment(node, literalName, node.initializer);
}
return node;
}
/**
* If an identifier name is a reserved word, returns a string literal for the name.
*
* @param name An Identifier
*/
function trySubstituteReservedName(name: Identifier) {
const token = name.originalKeywordKind || (nodeIsSynthesized(name) ? stringToToken(name.text) : undefined);
if (token >= SyntaxKind.FirstReservedWord && token <= SyntaxKind.LastReservedWord) {
return createLiteral(name, /*location*/ name);
}
return undefined;
}
}
}

View file

@ -955,39 +955,19 @@ namespace ts {
const declaration = resolver.getReferencedImportDeclaration(node);
if (declaration) {
if (isImportClause(declaration)) {
if (languageVersion >= ScriptTarget.ES5) {
return createPropertyAccess(
getGeneratedNameForNode(declaration.parent),
createIdentifier("default"),
/*location*/ node
);
}
else {
// TODO: ES3 transform to handle x.default -> x["default"]
return createElementAccess(
getGeneratedNameForNode(declaration.parent),
createLiteral("default"),
/*location*/ node
);
}
return createPropertyAccess(
getGeneratedNameForNode(declaration.parent),
createIdentifier("default"),
/*location*/ node
);
}
else if (isImportSpecifier(declaration)) {
const name = declaration.propertyName || declaration.name;
if (name.originalKeywordKind === SyntaxKind.DefaultKeyword && languageVersion <= ScriptTarget.ES3) {
// TODO: ES3 transform to handle x.default -> x["default"]
return createElementAccess(
getGeneratedNameForNode(declaration.parent.parent.parent),
createLiteral(name.text),
/*location*/ node
);
}
else {
return createPropertyAccess(
getGeneratedNameForNode(declaration.parent.parent.parent),
getSynthesizedClone(name),
/*location*/ node
);
}
return createPropertyAccess(
getGeneratedNameForNode(declaration.parent.parent.parent),
getSynthesizedClone(name),
/*location*/ node
);
}
}
}
@ -1024,15 +1004,10 @@ namespace ts {
function createExportAssignment(name: Identifier, value: Expression) {
return createAssignment(
name.originalKeywordKind === SyntaxKind.DefaultKeyword && languageVersion === ScriptTarget.ES3
? createElementAccess(
createIdentifier("exports"),
createLiteral(name.text)
)
: createPropertyAccess(
createIdentifier("exports"),
getSynthesizedClone(name)
),
createPropertyAccess(
createIdentifier("exports"),
getSynthesizedClone(name)
),
value
);
}

View file

@ -19,7 +19,6 @@ namespace ts {
const compilerOptions = context.getCompilerOptions();
const resolver = context.getEmitResolver();
const host = context.getEmitHost();
const languageVersion = getEmitScriptTarget(compilerOptions);
const previousOnSubstituteNode = context.onSubstituteNode;
const previousOnEmitNode = context.onEmitNode;
context.onSubstituteNode = onSubstituteNode;
@ -1312,12 +1311,7 @@ namespace ts {
return undefined;
}
if (name.originalKeywordKind && languageVersion === ScriptTarget.ES3) {
return createElementAccess(importAlias, createLiteral(name.text));
}
else {
return createPropertyAccess(importAlias, getSynthesizedClone(name));
}
return createPropertyAccess(importAlias, getSynthesizedClone(name));
}
function collectDependencyGroups(externalImports: (ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration)[]) {

View file

@ -26,6 +26,7 @@
"transformers/jsx.ts",
"transformers/es7.ts",
"transformers/es6.ts",
"transformers/es5.ts",
"transformers/generators.ts",
"transformers/destructuring.ts",
"transformers/module/module.ts",

View file

@ -28,6 +28,7 @@
"../compiler/transformers/jsx.ts",
"../compiler/transformers/es7.ts",
"../compiler/transformers/es6.ts",
"../compiler/transformers/es5.ts",
"../compiler/transformers/generators.ts",
"../compiler/transformers/destructuring.ts",
"../compiler/transformers/module/module.ts",

View file

@ -27,6 +27,7 @@
"../compiler/transformers/jsx.ts",
"../compiler/transformers/es7.ts",
"../compiler/transformers/es6.ts",
"../compiler/transformers/es5.ts",
"../compiler/transformers/generators.ts",
"../compiler/transformers/destructuring.ts",
"../compiler/transformers/module/module.ts",

View file

@ -13,5 +13,5 @@ Foo.default.default.foo();
//// [a.js]
"use strict";
var Foo = require("./b");
Foo.default.bar();
Foo.default.default.foo();
Foo["default"].bar();
Foo["default"]["default"].foo();

View file

@ -146,12 +146,12 @@ var x;
var arr;
var foo;
var fooProm;
fooProm = Promise.try(Promise, function () {
fooProm = Promise["try"](Promise, function () {
return foo;
});
fooProm = Promise.try(Promise, function () {
fooProm = Promise["try"](Promise, function () {
return foo;
}, arr);
fooProm = Promise.try(Promise, function () {
fooProm = Promise["try"](Promise, function () {
return foo;
}, arr, x);

View file

@ -7,6 +7,6 @@ class C {
var C = (function () {
function C() {
}
C.try = function () { };
C["try"] = function () { };
return C;
}());

View file

@ -292,7 +292,7 @@ var TypeScriptAllInOne;
(function (TypeScriptAllInOne) {
var Program = (function () {
function Program() {
this.case = bfs.STATEMENTS(4);
this["case"] = bfs.STATEMENTS(4);
}
Program.Main = function () {
var args = [];
@ -305,13 +305,13 @@ var TypeScriptAllInOne;
retValue = bfs.VARIABLES();
if (retValue != 0)
^= {
return: 1
"return": 1
};
}
finally {
}
};
Program.prototype.if = function (retValue) {
Program.prototype["if"] = function (retValue) {
if (retValue === void 0) { retValue = != 0; }
return 1;
^
@ -327,7 +327,7 @@ var TypeScriptAllInOne;
return 1;
}
};
Program.prototype.catch = function (e) {
Program.prototype["catch"] = function (e) {
console.log(e);
};
return Program;
@ -364,7 +364,7 @@ var BasicFeatures = (function () {
;
var quoted = '"', quoted2 = "'";
var reg = /\w*/;
var objLit = { "var": number = 42, equals: function (x) { return x["var"] === 42; }, instanceof: function () { return 'objLit{42}'; } };
var objLit = { "var": number = 42, equals: function (x) { return x["var"] === 42; }, "instanceof": function () { return 'objLit{42}'; } };
var weekday = Weekdays.Monday;
var con = char + f + hexchar + float.toString() + float2.toString() + reg.toString() + objLit + weekday;
//

View file

@ -344,43 +344,43 @@ var bigObject = {
string: 0,
get: 0,
yield: 0,
break: 0,
case: 0,
catch: 0,
class: 0,
continue: 0,
const: 0,
debugger: 0,
"break": 0,
"case": 0,
"catch": 0,
"class": 0,
"continue": 0,
"const": 0,
"debugger": 0,
declare: 0,
default: 0,
delete: 0,
do: 0,
else: 0,
enum: 0,
export: 0,
extends: 0,
false: 0,
finally: 0,
for: 0,
function: 0,
if: 0,
import: 0,
in: 0,
instanceof: 0,
new: 0,
null: 0,
return: 0,
super: 0,
switch: 0,
this: 0,
throw: 0,
true: 0,
try: 0,
typeof: 0,
var: 0,
void: 0,
while: 0,
with: 0
"default": 0,
"delete": 0,
"do": 0,
"else": 0,
"enum": 0,
"export": 0,
"extends": 0,
"false": 0,
"finally": 0,
"for": 0,
"function": 0,
"if": 0,
"import": 0,
"in": 0,
"instanceof": 0,
"new": 0,
"null": 0,
"return": 0,
"super": 0,
"switch": 0,
"this": 0,
"throw": 0,
"true": 0,
"try": 0,
"typeof": 0,
"var": 0,
"void": 0,
"while": 0,
"with": 0
};
var bigClass = (function () {
function bigClass() {
@ -401,43 +401,43 @@ var bigClass = (function () {
this.string = 0;
this.get = 0;
this.yield = 0;
this.break = 0;
this.case = 0;
this.catch = 0;
this.class = 0;
this.continue = 0;
this.const = 0;
this.debugger = 0;
this["break"] = 0;
this["case"] = 0;
this["catch"] = 0;
this["class"] = 0;
this["continue"] = 0;
this["const"] = 0;
this["debugger"] = 0;
this.declare = 0;
this.default = 0;
this.delete = 0;
this.do = 0;
this.else = 0;
this.enum = 0;
this.export = 0;
this.extends = 0;
this.false = 0;
this.finally = 0;
this.for = 0;
this.function = 0;
this.if = 0;
this.import = 0;
this.in = 0;
this.instanceof = 0;
this.new = 0;
this.null = 0;
this.return = 0;
this.super = 0;
this.switch = 0;
this.this = 0;
this.throw = 0;
this.true = 0;
this.try = 0;
this.typeof = 0;
this.var = 0;
this.void = 0;
this.while = 0;
this.with = 0;
this["default"] = 0;
this["delete"] = 0;
this["do"] = 0;
this["else"] = 0;
this["enum"] = 0;
this["export"] = 0;
this["extends"] = 0;
this["false"] = 0;
this["finally"] = 0;
this["for"] = 0;
this["function"] = 0;
this["if"] = 0;
this["import"] = 0;
this["in"] = 0;
this["instanceof"] = 0;
this["new"] = 0;
this["null"] = 0;
this["return"] = 0;
this["super"] = 0;
this["switch"] = 0;
this["this"] = 0;
this["throw"] = 0;
this["true"] = 0;
this["try"] = 0;
this["typeof"] = 0;
this["var"] = 0;
this["void"] = 0;
this["while"] = 0;
this["with"] = 0;
}
return bigClass;
}());

View file

@ -27,7 +27,7 @@ b2({ while: 1 });
"use strict";
// Error
function a(_a) {
var = _a.while;
var = _a["while"];
}
function a1(_a) {
var public = _a.public;
@ -56,13 +56,13 @@ function a7() {
a[_i - 0] = arguments[_i];
}
}
a({ while: 1 });
a({ "while": 1 });
// No Error
function b1(_a) {
var x = _a.public;
}
function b2(_a) {
var y = _a.while;
var y = _a["while"];
}
b1({ public: 1 });
b2({ while: 1 });
b2({ "while": 1 });

View file

@ -23,7 +23,7 @@ var C1T5 = (function () {
}());
var bigClass = (function () {
function bigClass() {
this.break = 1;
this["break"] = 1;
}
return bigClass;
}());

View file

@ -20,7 +20,7 @@ foo(function () {
}
return 0;
});
foo((1), { return: 0 });
foo((1), { "return": 0 });
foo(function (x) { return x; });
foo(function (x) {
if (x === void 0) { x = 0; }

View file

@ -12,7 +12,7 @@ var q = a["if"];
//// [keywordField.js]
var obj = {};
obj.if = 1;
var a = { if: "test" };
var n = a.if;
obj["if"] = 1;
var a = { "if": "test" };
var n = a["if"];
var q = a["if"];

View file

@ -9,6 +9,6 @@ declare var React: any;
//// [keywordInJsxIdentifier.js]
React.createElement("foo", { "class-id": true });
React.createElement("foo", { class: true });
React.createElement("foo", { "class": true });
React.createElement("foo", { "class-id": "1" });
React.createElement("foo", { class: "1" });
React.createElement("foo", { "class": "1" });

View file

@ -38,5 +38,5 @@ function foo() {
}());
}
var x = {
class: C4
"class": C4
}, _a = void 0;

View file

@ -3,4 +3,4 @@
var { while } = { while: 1 }
//// [objectBindingPatternKeywordIdentifiers01.js]
var = { while: 1 }.while;
var = { "while": 1 }["while"];

View file

@ -3,4 +3,4 @@
var { while: while } = { while: 1 }
//// [objectBindingPatternKeywordIdentifiers02.js]
var _a = { while: 1 }, = _a.while, = _a.while;
var _a = { "while": 1 }, = _a["while"], = _a["while"];

View file

@ -3,4 +3,4 @@
var { "while" } = { while: 1 }
//// [objectBindingPatternKeywordIdentifiers03.js]
var = { while: 1 }["while"];
var = { "while": 1 }["while"];

View file

@ -3,4 +3,4 @@
var { "while": while } = { while: 1 }
//// [objectBindingPatternKeywordIdentifiers04.js]
var _a = { while: 1 }, = _a["while"], = _a.while;
var _a = { "while": 1 }, = _a["while"], = _a["while"];

View file

@ -27,15 +27,15 @@ var y = {
42: ,
get e() { },
set f() { },
this: ,
super: ,
var: ,
class: ,
typeof:
"this": ,
"super": ,
"var": ,
"class": ,
"typeof":
};
var x = {
a: .b,
a: ["ss"],
a: [1]
};
var v = { class: }; // error
var v = { "class": }; // error

View file

@ -91,7 +91,7 @@ var C = (function () {
return C;
}());
var a;
var b = { new: function (x) { return ''; } }; // not a construct signature, function called new
var b = { "new": function (x) { return ''; } }; // not a construct signature, function called new
function foo1b(x) { }
function foo1c(x) { }
function foo2(x) { }

View file

@ -91,7 +91,7 @@ var C = (function () {
return C;
}());
var a;
var b = { new: function (x) { return ''; } }; // not a construct signature, function called new
var b = { "new": function (x) { return ''; } }; // not a construct signature, function called new
function foo1b(x) { }
function foo1c(x) { }
function foo2(x) { }

View file

@ -92,7 +92,7 @@ var C = (function () {
return C;
}());
var a;
var b = { new: function (x) { return ''; } }; // not a construct signature, function called new
var b = { "new": function (x) { return ''; } }; // not a construct signature, function called new
function foo1b(x) { }
function foo1c(x) { }
function foo2(x) { }

View file

@ -109,7 +109,7 @@ var D = (function () {
return D;
}());
var a;
var b = { new: function (x, y) { return ''; } }; // not a construct signature, function called new
var b = { "new": function (x, y) { return ''; } }; // not a construct signature, function called new
function foo1b(x) { }
function foo1c(x) { }
function foo2(x) { }

View file

@ -128,7 +128,7 @@ var D = (function () {
return D;
}());
var a;
var b = { new: function (x, y) { return ''; } }; // not a construct signature, function called new
var b = { "new": function (x, y) { return ''; } }; // not a construct signature, function called new
function foo1b(x) { }
function foo1c(x) { }
function foo2(x) { }

View file

@ -99,7 +99,7 @@ var C = (function () {
return C;
}());
var a;
var b = { new: function (x) { return null; } }; // not a construct signature, function called new
var b = { "new": function (x) { return null; } }; // not a construct signature, function called new
function foo1b(x) { }
function foo1c(x) { }
function foo2(x) { }

View file

@ -95,7 +95,7 @@ var C = (function () {
return C;
}());
var a;
var b = { new: function (x) { return null; } }; // not a construct signature, function called new
var b = { "new": function (x) { return null; } }; // not a construct signature, function called new
function foo1b(x) { }
function foo1c(x) { }
function foo2(x) { }

View file

@ -87,7 +87,7 @@ var C = (function () {
return C;
}());
var a;
var b = { new: function (x) { return x; } };
var b = { "new": function (x) { return x; } };
function foo1b(x) { }
function foo1c(x) { }
function foo2(x) { }

View file

@ -87,7 +87,7 @@ var C = (function () {
return C;
}());
var a;
var b = { new: function (x) { return new C(x); } };
var b = { "new": function (x) { return new C(x); } };
function foo1b(x) { }
function foo1c(x) { }
function foo2(x) { }

View file

@ -91,7 +91,7 @@ var C = (function () {
return C;
}());
var a;
var b = { new: function (x, y) { return new C(x, y); } }; // not a construct signature, function called new
var b = { "new": function (x, y) { return new C(x, y); } }; // not a construct signature, function called new
function foo1b(x) { }
function foo1c(x) { }
function foo2(x) { }

View file

@ -91,7 +91,7 @@ var C = (function () {
return C;
}());
var a;
var b = { new: function (x, y) { return new C(x, y); } }; // not a construct signature, function called new
var b = { "new": function (x, y) { return new C(x, y); } }; // not a construct signature, function called new
function foo1b(x) { }
function foo1c(x) { }
function foo2(x) { }

View file

@ -91,7 +91,7 @@ var C = (function () {
return C;
}());
var a;
var b = { new: function (x, y) { return new C(x, y); } }; // not a construct signature, function called new
var b = { "new": function (x, y) { return new C(x, y); } }; // not a construct signature, function called new
function foo1b(x) { }
function foo1c(x) { }
function foo2(x) { }

View file

@ -4,4 +4,4 @@ return;
//// [parserErrorRecovery_ObjectLiteral2.js]
var v = { a: ,
return: };
"return": };

View file

@ -4,4 +4,4 @@ return;
//// [parserErrorRecovery_ObjectLiteral3.js]
var v = { a: ,
return: };
"return": };

View file

@ -4,4 +4,4 @@ return;
//// [parserErrorRecovery_ObjectLiteral4.js]
var v = { a: 1,
return: };
"return": };

View file

@ -4,4 +4,4 @@ return;
//// [parserErrorRecovery_ObjectLiteral5.js]
var v = { a: 1,
return: };
"return": };

View file

@ -9,4 +9,4 @@ var x = f.export();
//// [parserExportAsFunctionIdentifier.js]
var f;
var x = f.export();
var x = f["export"]();

View file

@ -8,7 +8,7 @@ var big = {
//// [parserKeywordsAsIdentifierName1.js]
var big = {
break: 0,
super: 0,
const: 0
"break": 0,
"super": 0,
"const": 0
};

View file

@ -2,4 +2,4 @@
var v = { class };
//// [parserShorthandPropertyAssignment2.js]
var v = { class: };
var v = { "class": };

View file

@ -10,7 +10,7 @@ var C = (function () {
function C() {
}
C.prototype.M = function () {
this.super(0);
this["super"](0);
};
return C;
}());

View file

@ -12,4 +12,4 @@ i.const.prototype.prop = "yo";
//// [prototypeOnConstructorFunctions.js]
var i;
i.const.prototype.prop = "yo";
i["const"].prototype.prop = "yo";

View file

@ -19,16 +19,16 @@ var obj2 = {
//// [reservedWords.js]
var obj = {
if: 0,
debugger: 2,
break: 3,
function: 4
"if": 0,
"debugger": 2,
"break": 3,
"function": 4
};
//This compiles.
var obj2 = {
if: 0,
while: 1,
debugger: 2,
break: 3,
function: 4
"if": 0,
"while": 1,
"debugger": 2,
"break": 3,
"function": 4
};

View file

@ -27,8 +27,8 @@ function () { }
throw function () { };
module;
void {};
var _a = { while: 1, return: 2 }, = _a.while, = _a.return;
var _b = { this: 1, switch: { continue: 2 } }, = _b.this, = _b.switch.continue;
var _a = { "while": 1, "return": 2 }, = _a["while"], = _a["return"];
var _b = { "this": 1, "switch": { "continue": 2 } }, = _b["this"], = _b["switch"]["continue"];
var _c = void 0;
debugger;
if ()

View file

@ -97,7 +97,7 @@ var SubSub1 = (function (_super) {
return _super.apply(this, arguments) || this;
}
SubSub1.prototype.bar = function () {
return _super.prototype.super.foo;
return _super.prototype["super"].foo;
};
return SubSub1;
}(Sub1));

View file

@ -38,21 +38,21 @@ let render = (ctrl, model) =>
//// [file.js]
// A simple render function with nesting and control statements
var render = function (ctrl, model) {
return vdom.createElement("section", { class: "todoapp" },
vdom.createElement("header", { class: "header" },
return vdom.createElement("section", { "class": "todoapp" },
vdom.createElement("header", { "class": "header" },
vdom.createElement("h1", null, "todos <x>"),
vdom.createElement("input", { class: "new-todo", autofocus: true, autocomplete: "off", placeholder: "What needs to be done?", value: model.newTodo, onKeyup: ctrl.addTodo.bind(ctrl, model) })),
vdom.createElement("section", { class: "main", style: { display: (model.todos && model.todos.length) ? "block" : "none" } },
vdom.createElement("input", { class: "toggle-all", type: "checkbox", onChange: ctrl.toggleAll.bind(ctrl) }),
vdom.createElement("ul", { class: "todo-list" }, model.filteredTodos.map(function (todo) {
return vdom.createElement("li", { class: { todo: true, completed: todo.completed, editing: todo == model.editedTodo } },
vdom.createElement("div", { class: "view" },
vdom.createElement("input", { "class": "new-todo", autofocus: true, autocomplete: "off", placeholder: "What needs to be done?", value: model.newTodo, onKeyup: ctrl.addTodo.bind(ctrl, model) })),
vdom.createElement("section", { "class": "main", style: { display: (model.todos && model.todos.length) ? "block" : "none" } },
vdom.createElement("input", { "class": "toggle-all", type: "checkbox", onChange: ctrl.toggleAll.bind(ctrl) }),
vdom.createElement("ul", { "class": "todo-list" }, model.filteredTodos.map(function (todo) {
return vdom.createElement("li", { "class": { todo: true, completed: todo.completed, editing: todo == model.editedTodo } },
vdom.createElement("div", { "class": "view" },
(!todo.editable) ?
vdom.createElement("input", { class: "toggle", type: "checkbox" })
vdom.createElement("input", { "class": "toggle", type: "checkbox" })
: null,
vdom.createElement("label", { onDoubleClick: function () { ctrl.editTodo(todo); } }, todo.title),
vdom.createElement("button", { class: "destroy", onClick: ctrl.removeTodo.bind(ctrl, todo) }),
vdom.createElement("div", { class: "iconBorder" },
vdom.createElement("div", { class: "icon" }))));
vdom.createElement("button", { "class": "destroy", onClick: ctrl.removeTodo.bind(ctrl, todo) }),
vdom.createElement("div", { "class": "iconBorder" },
vdom.createElement("div", { "class": "icon" }))));
}))));
};

View file

@ -21,9 +21,9 @@ var Controller = (function () {
}
Controller.prototype.create = function () {
};
Controller.prototype.delete = function () {
Controller.prototype["delete"] = function () {
};
Controller.prototype.var = function () {
Controller.prototype["var"] = function () {
};
return Controller;
}());