3 ms·
Rainbow["onHighlight"] = Rainbow.onHighlight; Isn't that line useless since `obj['property'] == obj.property` is always true? https://github.com/ccampbell/rai
by olalonde 15y ago
Rainbow["onHighlight"] = Rainbow.onHighlight;
Isn't that line useless since `obj['property'] == obj.property` is always true?
https://github.com/ccampbell/rainbow/blob/master/js/rainbow.js#L636 https://github.com/ccampbell/rainbow/blob/master/js/rainbow....
- mattpodwysocki 15y agoNo, it's not useless when it comes to advanced minimization when Rainbow.onHighlight might be minimized to Rainbox.a. By doing Rainbow['onHighlight'] ensures a method called onHighlight exists on the Rainbow object.
- craigc 15y agoThis is because I'm using Google Closure Compiler in advanced mode so all methods that do not get used get renamed. In order to preserve the methods and keep them public you have to reference them like this.
- oinksoft 15y agoThis is what @export (and the related functions in the library for if you are not using annotations) are for. In the context of Closure, this is clumsy. But I expect that not all other minifiers offer the same flexibility.