I have a function that checks that the callback methods within an object exist. Currently the Closure Compiler renames the methods (onClickDisplay and onCloseHide) so all the checks in makeCallbacks() fail.
Is there a way to tell the Closure Compiler to not rename the methods (onClickDisplay and onCloseHide) or tell the Compiler to also rename the method names in callbackNames()
makeCallbacks = function(tobject, methodNames) {
var callbacks = {};
methodNames.each(function(methodName) {
if (!tobject[methodName]) {
throw new Error(methodName + ' missing from ' + tobject.toString());
}
callbacks[methodName] = tobject[methodName].bind(tobject);
});
return callbacks;
};
FeedbackController = Class.create({
initialize: function(id, item) {
this.callbacks = makeCallbacks(this, this.callbackNames());
},
observeElements: function() {
$$(this.id + ' .closeme').invoke('observe', 'click', this.callbacks.onCloseHide);
},
callbackNames: function() {
return ['onClickDisplay', 'onCloseHide'];
},
onClickDisplay: function(e) {
// do something
},
onCloseHide: function(e) {
// do something
}
});