Closed kapooostin closed 13 years ago
Thanks -- this should now be fixed on master.
Funnily enough, the Graphics desk here at the NYTimes also ran into this same bug -- they're using Underscore to script Illustrator, and I assume that all Adobe JS engines have this same operator precedence problem.
Great!
I didn't test it yet in Illustrator, but in InD I also changed the way how root
is defined. Inside function this
doesn't refer to global
, so I passed it as a parameter, exactly as it is implemented in underscore.string.js.
(function(root){
...
}(this || window));
Should I open an issue for this or there are reasons for global scope not to be passed to module as a parameter?
Yes -- if you want to change the way that root is determined, you'll need to test it in browsers, Node.js, Rhino, JScript, Adobe, RingoJS, etc etc -- all of the runtimes.
The current way should be working properly, as other folks are using it successfully in Adobe products. Are you sure that this !== window
?
The fact that a product from Adobe has an operator precedence issue in their JS interpreter is astonishing. How can any serious piece of software include such a blatant flaw? I can only imagine that a single novice programmer has created their JS interpreter, and they don't have any operator precedence tests. That's pathetic. Shitty Adobe programmers strike again.
Yes. It throws an error. Here is a screenshot from of my tests http://db.tt/EHxdVDhF.
Actually this
refers to anonymous function, not global scope.
Does changing the wrapper to:
(function(){
...
}).call(this);
Fix the problem for you? If so, please open a pull request.
@kapooostin: What's the value of this
inside the function? null
?
@jashkenas: Yes, it solves the problem. Now _
is global. I'll open a pull request.
@michaelficarra: null
would be too stupid, even for adobejs. Here is console output http://db.tt/VeVTFWry.
Oh my god, functions are invoked with themselves as the context. Wow, I didn't realise just how bad that platform was...
@michaelficarra: you haven't tried to write scripts for Adobe Acrobat documents, I guess.
The context bug looks vaguely familiar...I think Windows Script Host under Windows XP does this as well.
It cannot assign value in the second part of conjunction. Adding braces solves it: