Got it, works now. Thanks! On Monday, February 2, 2015 at 11:24:57 AM UTC-7, Kevin Reid wrote: > > On Fri, Jan 30, 2015 at 3:49 PM, Jordan Last <[email protected] > <javascript:>> wrote: > >> I've found a work-around. I haven't tested it much, but it at least >> finishes off the caja.load from my example. I would like to know if my >> solution is suitable (not dangerous to security) and if this is a problem >> that needs to be fixed with Caja itself. >> >> Here is the work-around: >> >> Take a look at line 27344 of ses-single-frame.js >> var divInfo = cajaInt.prepareContainerDiv(div, feralWin, domOpts); >> >> divInfo is what gets passed on to other functions that need to access the >> nodeType and ownerDocument of the property opt_div which is a property of >> divInfo. But opt_div is one level too deep it seems, and therefore its >> nodeType and ownerDocument are one level too deep as well. My work-around >> was to add this line just below the line above: >> divInfo.opt_div = divInfo.opt_div[0]; >> That line assigned opt_div to actually be the element at key value 0, >> which is what I think opt_div is supposed to be anyway. I'm not sure if all >> of my rationale is correct, but it works now, and it would be nice to get >> this fixed so that I don't have to serve up a hacked copy of caja. Thanks! >> > > That value should be an element node. If it's something else, then you've > passed the wrong thing into caja.load. > > Consulting the AngularJS documentation, I found a statement that the > second argument to the link function is not a DOM node but "the > jqLite-wrapped element". So you need to unwrap it before passing it to > caja.load. > > >> On Friday, January 30, 2015 at 1:06:38 PM UTC-7, Jordan Last wrote: >>> >>> ... >>> angular.module('testModule').directive('smCaja', [ >>> function() { >>> return { >>> restrict: 'E', >>> link: function postLink(scope, element, attrs) { >>> caja.initialize( >>> { >>> cajaServer: '//caja.appspot.com/', >>> debug: true, >>> maxAcceptableSeverity: 'NO_KNOWN_EXPLOIT_SPEC_VIOLATION' >>> }); >>> caja.load(element, undefined, function(frame) >>> { >>> caja.markFunction(scope.receiveData); >>> var tamedReceiveData = caja.tame(scope.receiveData); >>> >>> frame.code('api/practiceproblem/1', "text/html").api({ transferData: >>> tamedReceiveData }).run(function(result) >>> { >>> alert('good job!'); >>> }); >>> }); >>> scope.receiveData = function(arg1, arg2, arg3, arg4) { >>> }; >>> } >>> }; >>> } >>> ]); >>> >> >
-- --- 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/d/optout.
