Yeah,  I just got rid of the nested loadModule.

Mark and I seem to differ in opinion, and I haven't heard his reasons, and
I'd like to do that before debating the merits of treating a script block
within an html document as a compilation unit instead of treating the whole
html doc as one compilation unit.

This seems complicated though.


2008/9/29 Felix <[EMAIL PROTECTED]>

>
> didn't mikesamuel fix this yesterday?
>
> Mike Stay wrote:
> > Ben, Ihab, Jasvir, and I discussed this morning how to address the
> > problem of cajoling a gadget in cajita mode.  At the moment, a gadget
> > like
> >
> > <script>
> >   script_code;
> > </script>
> > <div onclick = "onclickCode();">Click me</div>
> >
> > cajoles into (roughly)
> >
> > ___.loadModule(function (___, IMPORTS___) {
> >   // definition of click handler
> >   ___.loadModule(function (___, IMPORTS___) {
> >     return script_code;
> >   });
> >   // htmlEmitter stuff including a reference to IMPORTS___
> >   // for the click handler
> > });
> >
> > All the IMPORTS___ objects are the same, because the
> > setNewModuleHandler function is in ___ and cajita code can't access
> > it.
> >
> > If the script block wants to share variables with the event handler,
> > then the containing page that loads this gadget has to put an object
> > into IMPORTS___ with mutable state:
> >
> > var imports = ___.getNewModuleHandler.getImports();
> > imports.sharedState = {};
> > ___.getNewModuleHandler.setImports(imports);
> >
> > after which, the gadget code can say
> >
> > <script>
> >   sharedState.clicky = function(){
> >     // do something;
> >   }
> > </script>
> > <div onclick = "sharedState.clicky()">Click me!</div>
> >
> > This pattern places the decision about where the state sharing occurs
> > too high up the chain of control: the gadget, not the container,
> > should decide what state is shared between two script blocks within
> > the gadget.
> >
> > We propose adding an attribute to the script tag, "cajita_vars", that
> > contains a list of variable names:
> >
> > <script cajita_vars = "foo, bar">
> >   foo.x = function(){
> >     // attenuation of authority in bar
> >   };
> > </script>
> > <div>Blah blah</div>
> > <script cajita_vars = "foo, baz">
> >   baz.clicky = function(){
> >     ...
> >     // use of attenuated authority
> >     foo.x();
> >     ...
> >   }
> > </script>
> > <div onclick = "baz.clicky()" cajita_vars = "baz">Click Me!</div>
> >
> > The union of these names ({foo, bar, baz} in the above) are declared
> > as properties of a begotten IMPORTS___ object as the first statement
> > in the gadget's module function and initialized to an empty record:
> >
> > ___.loadModule(function (___, IMPORTS___) {
> >   var imports = cajita.beget(IMPORTS___);
> >
> >   // vvvvvvvvvvvv
> >   imports.foo = {};
> >   imports.bar = {};
> >   imports.baz = {}
> >   ___.getNewModuleHandler().setImports(imports);
> >   // ^^^^^^^^^^^^
> >
> >   ___.loadModule(function (___, IMPORTS___) {
> >     var foo = ___.readImport(IMPORTS___, 'foo');
> >     var bar = ___.readImport(IMPORTS___, 'bar');
> >     // setPub on foo, readpub on bar
> >   });
> >   ___.loadModule(function (___, IMPORTS___) {
> >     var foo = ___.readImport(IMPORTS___, 'foo');
> >     var baz = ___.readImport(IMPORTS___, 'baz');
> >     // setpub on baz, readpub on foo
> >   });
> >   // htmlEmitter stuff including a reference to IMPORTS___
> >   // for the click handler and a readPub on baz
> >
> >   // vvvvvvvvvvvv
> >   ___.getNewModuleHandler().setImports(IMPORTS___);
> >   // ^^^^^^^^^^^^
> > });
> >
> > Also, rather than grant ambient authority to every script block to
> > access the whole dom tree under IMPORTS___.document, we propose an
> > attribute "cajita_doc" that is given the id of a tag on the page:
> >
> > <div id="foo">Hello,</div>
> > <script cajita_doc = "foo">
> > document.body.innerHTML="World!";
> > </script>
> >
> > <div id="bar">IM IN UR</div>
> > <script cajita_doc = "bar">
> > document.body.innerHTML="GAJIT";
> > </script>
> >
> > Comments / corrections?
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to 
http://groups.google.com/group/google-caja-discuss
To unsubscribe, email [EMAIL PROTECTED]
-~----------~----~----~----~------~----~------~--~---

Reply via email to