I wrote some javascript code relying on Prototype.js.
Prototype.js's way to define classes is the following:
var Person = Class.create({
initialize: function(name) {
this.name = name;
},
say: function(message) {
return this.name + ': ' + message;
}
});
All the keys passed to Class.create
will be added to Person.prototype
. With this mechanism Prototype.js is able to offer inheritance. [link]
Closure compiler now complains because it thinks that those initialize
and say
functions are "neither a prototype method nor marked as a constructor". [link, check: JCS_UNSAFE_THIS]
Is there any way to fix this?