When I run caja.load on my own AngularJS directive, I get this
error: Uncaught TypeError: Cannot read property 'nodeType' of undefined -
line 17047 of ses-single-frame.js?debug=1
HTML:
<div>
<sm-caja id="cajaElement"></sm-caja>
</div>
AngularJS directive:
'use strict';
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) {
};
}
};
}
]);
I dug into it a little bit, and my sm-caja element has a nodeType property
when I inspect it in the Chrome Dev tools debugger, but it is undefined
when accessed in the code. The part of the code where the error is
occurring looks like it needs a document object, so I tried passing in the
$document object into caja.load from my directive code, and I changed the
parameters of each function call until I passed the document object down to
where the error occurred on line 17047, and set var document = [the
document object I passed in from my directive]. But that caused problems at
other places in the code with more undefined values. Any help would be
appreciated. I'm using build 5707 from the caja.appspot.com servers, and
I'm running Chrome Version 38.0.2125.122 (64-bit) on Ubuntu 14.04 LTS
--
---
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.