Updates:
        Status: New
        Owner: ---

Comment #2 on issue 1110 by mikesamuel: Exception var in remote script conflicts with page global var, preventing cajole
http://code.google.com/p/google-caja/issues/detail?id=1110

I'm withdrawing the fix.

The problem is that the example as given is problematic.

If the example were instead,

file x.js
(function () {
    try { throw new Error(); } catch (x) {}
})();

page.html
<!doctype html><head></head><body onload=alert(x)>
<script>var x = 'boom';</script>
<script src="x.js"></script>
</body></html>

then, on IE 6, it would alert [object Error].


To fix the first example without breaking on the second example we could try a few
things:
(1) detect order of initialization and use
(2) optimize out try/catch blocks with a try body that can never throw.
(3) rename catch variables and their uses according to correct scoping rules and
create local variables as necessary.

(1) is hard.
(2) won't solve the underlying problem of scope inconsistencies, and is hard to do except in trivial cases as in the first example. For the cases we can optimize, I
would advise people to just not have try/catch blocks they don't need.
(3) is possible using the alpha-renamer but we need to think long and hard about
debuggability before we do that.


--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings

Reply via email to