Revision: 4234
Author: [email protected]
Date: Mon Aug 9 17:19:36 2010
Log: Eliminate dependency from caja-iframe.js to
demos/playground/setup-valija.js.
http://codereview.appspot.com/1942041
THe replacement, plugin/capture-valija.js, also restores the original new
module handler.
[email protected]
http://code.google.com/p/google-caja/source/detail?r=4234
Added:
/trunk/src/com/google/caja/plugin/capture-valija.js
Modified:
/trunk/build.xml
=======================================
--- /dev/null
+++ /trunk/src/com/google/caja/plugin/capture-valija.js Mon Aug 9 17:19:36
2010
@@ -0,0 +1,37 @@
+/**
+ * @fileoverview
+ * Given that the next script executed is the cajoled Valija module, make
+ * valijaMaker available in the global scope.
+ *
+ * @author [email protected]
+ * @author [email protected]
+ * @requires ___
+ * @provides valijaMaker
+ */
+
+var valijaMaker = undefined;
+(function(){
+ // Save and restore
+ var originalNewModuleHandler = ___.getNewModuleHandler();
+
+ // Set up a fresh handler
+ var ourHandler = ___.makeNormalNewModuleHandler();
+
+ // ... which captures Valija
+ var imports = ourHandler.getImports();
+ imports.loader = {
+ provide: ___.markFuncFreeze(function (v) {
+ valijaMaker = v;
+ })
+ };
+ imports.outers = imports;
+
+ // ... and removes itself.
+ var normalHandle = ourHandler.handle;
+ ourHandler.handle = ___.markFuncFreeze(function (module) {
+ ___.setNewModuleHandler(originalNewModuleHandler);
+ normalHandle.call(ourHandler, module);
+ });
+
+ ___.setNewModuleHandler(ourHandler);
+})();
=======================================
--- /trunk/build.xml Fri Aug 6 14:31:46 2010
+++ /trunk/build.xml Mon Aug 9 17:19:36 2010
@@ -657,7 +657,7 @@
<input file="${src}/com/google/caja/plugin/html-emitter.js"/>
<input file="${src}/com/google/caja/plugin/bridal.js"/>
<input file="${src}/com/google/caja/plugin/domita.js"/>
- <input
file="${src}/com/google/caja/demos/playground/setup-valija.js"/>
+ <input file="${src}/com/google/caja/plugin/capture-valija.js"/>
<input file="${lib}/com/google/caja/plugin/valija.out.js"/>
<input file="${src}/com/google/caja/plugin/uri.js"/>
<input file="${src}/com/google/caja/cajita-module.js"/>
@@ -678,7 +678,7 @@
<input file="${src}/com/google/caja/plugin/html-emitter.js"/>
<input file="${src}/com/google/caja/plugin/bridal.js"/>
<input file="${src}/com/google/caja/plugin/domita.js"/>
- <input
file="${src}/com/google/caja/demos/playground/setup-valija.js"/>
+ <input file="${src}/com/google/caja/plugin/capture-valija.js"/>
<input file="${lib}/com/google/caja/plugin/valija.out.js"/>
<input file="${src}/com/google/caja/plugin/uri.js"/>
<input file="${src}/com/google/caja/cajita-module.js"/>