addyosmani/aura — pull request #151 by atesgoral (2012-11-05 04:38:31+00:00)
Title: Individual sandbox injection into widgets

Turned sandbox modules into sandbox factories. Added RequireJS path mapping to replace widget sandboxes with individual sandbox instances.

At a high level, there are three main changes:

1. Allowing apps to extend both Core and Sandbox was making it hard to apply a sandbox factory. Seeing to immediate reason for the Core Backbone extension, I've removed it and moved its code to the Sandbox Backbone extension. I think philosophically letting apps only tweak the Sandbox would be more straightforward.

2. To be able to assign a new Sandbox instance to each widget, there should no longer be a global Sandbox instance. There could potentially be a Sandbox class defined, but for now I've taken the short route of converting the Sandbox definitions (Aura + Backbone extension) to be objects with just a `create` method that is the factory for a new Sandbox instance.

3. The Core load method has been embellished with a RequireJS module map configuration. I've tentatively used the "sandbox$<sequence>" convention to give sandbox instances unique module names, which later get mapped to "sandbox" using the map configuration, so the widget (and its submodules) grab the custom instance when they reference "sandbox".

I haven't taken the further step of defining a new context for widgets (via a `context: 'widget'` line in the `require.config` call). This can be tackled separately, if a real need is seen. This could essentially prevent widgets from directly accessing Aura modules and limit their access to just the sandbox (which then becomes a better facade).

Grunt status: JSLint passed. Getting stuck on Jasmine. Haven't investigated whether it's something I've introduced.