On Apr 20, 2013, at 12:00, [email protected] wrote: > Perhaps I've missed it in the docs, but is there a list of things one has to > do to their javascript to make it run under caja? > > For example, I got some of these messages in firebug console... > > LINT(3) TOP_LEVEL_FUNC_INCOMPATIBLE_WITH_CAJA: <snip long url> - 834+4: Caja > makes top-level functions local to a script tag. If you need a global > function, use: window[ 'cullProducts' ] = function () {}
This particular warning is actually obsolete due to a new rewriting stage that fixes that case; we haven't gotten around to throwing it out. > Is there a caja-compatible javascript style guide (or some standard style > guide) that you folks are coding to? To a point, it's been changing faster than we get around to updating documentation, which isn't very fast. Here's what I'd say are the major points to keep in mind. 0. On browsers which are insufficiently non-buggy to support SES (such as the one which you were using for your experiment above), nothing which is equivalent to eval() is supported (e.g. element.onclick = "some code as a string"). 1. Your code will be executed in strict mode, as if it had "use strict"; at the beginning. 2. Every singleton object provided by JS (Object, Object.prototype, Date, etc.) is _frozen_: it cannot be modified in any way. 3. The DOM interfaces are limited to things we have gotten around to making safe. -- Kevin Reid <http://switchb.org/kpreid/> -- --- You received this message because you are subscribed to the Google Groups "Google Caja Discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
