Broken in Opera 11.64 #26

Closed
gaomd opened this Issue May 12, 2012 · 2 comments

3 participants

@gaomd

Just tested with a simple HTML file:

<!DOCTYPE html>
<html>
  <head>
    <script type="text/javascript" src="https://raw.github.com/olado/doT/master/doT.js"></script>
  </head>
</html>

Got:

Uncaught exception: TypeError: Cannot convert 'global' to object

Error thrown at line 36, column 2 in <anonymous function>() in https://raw.github.com/olado/doT/master/doT.js:
    global.doT = doT;
called from line 7, column 0 in https://raw.github.com/olado/doT/master/doT.js:
    (function() {

Browser: Windows Opera 11.64 (latest version)
Related link: http://stackoverflow.com/q/10564463
But the minified version worked.

@kitcambridge

(0, eval) forces evaluation in the global scope, as it's an indirect call to eval. Unfortunately, Opera 11.6 incorrectly interprets (0 || eval) as a direct call—which causes evaluation to occur in the scope of the caller function.

The fix is to change line 29 to read like so:

var global = (function(){ return this || (0, eval)('this'); }());

The compressed version makes this change automatically, so that's why it works for you.

@olado olado closed this in e0adebb May 12, 2012
@olado
Owner

Thanks! (0 || eval) is slightly faster in v8 btw, but it does not matter here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment