Browse Source

Prototype/$extends jshint fixes.

Ensure a class prototype, when not using $extends has a semicolon
inserted after the prototype.

Class.prototype = {
     ...
}; <-- without, a jshint error.

Change inherit to Inherit and remove a semicolon after declaration.
Fixes 2 jshint errors about an unecessary semicolon, and constructor
names not starting with capital letter.
Luca Deltodesco 12 years ago
parent
commit
cd3bd512ec
1 changed files with 2 additions and 2 deletions
  1. 2 2
      genjs.ml

+ 2 - 2
genjs.ml

@@ -997,7 +997,7 @@ let generate_class ctx c =
 
 
 		bend();
 		bend();
 		print ctx "\n}";
 		print ctx "\n}";
-		(match c.cl_super with None -> () | _ -> print ctx ")");
+		(match c.cl_super with None -> ctx.separator <- true | _ -> print ctx ")");
 		newline ctx
 		newline ctx
 	end
 	end
 
 
@@ -1131,7 +1131,7 @@ let generate com =
 	);
 	);
 	if List.exists (function TClassDecl { cl_extern = false; cl_super = Some _ } -> true | _ -> false) com.types then begin
 	if List.exists (function TClassDecl { cl_extern = false; cl_super = Some _ } -> true | _ -> false) com.types then begin
 		print ctx "function $extend(from, fields) {
 		print ctx "function $extend(from, fields) {
-	function inherit() {}; inherit.prototype = from; var proto = new inherit();
+	function Inherit() {} Inherit.prototype = from; var proto = new Inherit();
 	for (var name in fields) proto[name] = fields[name];
 	for (var name in fields) proto[name] = fields[name];
 	if( fields.toString !== Object.prototype.toString ) proto.toString = fields.toString;
 	if( fields.toString !== Object.prototype.toString ) proto.toString = fields.toString;
 	return proto;
 	return proto;