在打包的应用中使用dojo 1.8(uncaught unload在打包的应用中不可用) [英] Using dojo 1.8 in a packaged app (uncaught unload is not available in packaged apps)
问题描述
$ b
在我的打包应用程序中使用dojo取得了一些进展后,我又碰到另一个路障,我找不到任何文档。 >
{
...
sandbox:{
pages:[test.html]
},
应用:{
background:{
scripts:[
background.js
]
}
}
}
test.html从应用程序加载dojo以及我的一些模块,但是dojo解析页面的dom中,我收到了platformApp抛出的错误
Uncaught unload在打包的应用程序中不可用。 platformApp:14
(匿名函数)platformApp:14
Window.addEventListener platformApp:127
addListener dojo.js.uncompressed.js:15317
on.parse
是否有任何CSP规则可以添加到沙盒中,以便这样做是正常的事情?
$ b $我希望Chrome默认是这样做的,而不是抛出一个错误......但这是我在加载dojo之前必须做的事情: //防止注册unload / beforeunload并发出警告,chrome会抛出异常。
(function(){
var windowAddEventListener = Window.prototype.addEventListener;
Window.prototype.addEventListener = function(type){
if(type ==='unload' || type ==='beforeunload'){
try {
throw new Error('不要使用Window.addEventListener for'+ type);
} catch(e){
console.error(e.message,e);
}
} else
return windowAddEventListener.apply(window,arguments);
};
}) ();
After finally making some progress in using dojo with my packaged app, I've hit another road block that I can't find any documentation for.
{
...
"sandbox": {
"pages": ["test.html"]
},
"app": {
"background": {
"scripts": [
"background.js"
]
}
}
}
test.html loads dojo from the app as well as some of my modules, but as dojo parses the dom of the page, I get an error thrown by the platformApp
Uncaught unload is not available in packaged apps. platformApp:14
(anonymous function) platformApp:14
Window.addEventListener platformApp:127
addListener dojo.js.uncompressed.js:15317
on.parse
Are there any CSP rules I can add to the sandbox to let this do it's normal thing?
I wish that chrome did this by default instead of throwing an error... but this is what I had to do before I loaded dojo:
// Prevent registrations for unload/beforeunload and warn, chrome will throw exception.
(function() {
var windowAddEventListener = Window.prototype.addEventListener;
Window.prototype.addEventListener = function(type) {
if (type === 'unload' || type === 'beforeunload') {
try {
throw new Error('Do not use Window.addEventListener for ' + type);
} catch (e) {
console.error(e.message, e);
}
} else
return windowAddEventListener.apply(window, arguments);
};
})();
这篇关于在打包的应用中使用dojo 1.8(uncaught unload在打包的应用中不可用)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!