我正在开发一个使用textAngular的角度应用程序,该应用程序取决于rangy-core和rangy-selectionsaverestore。我在使用最新的IE时遇到以下错误:
Module 'WrappedSelection' failed to load: Unspecified error.
Error: Unspecified error.
at Anonymous function (js/plugins/textAngular/rangy-core.js:2970:29)
at Anonymous function (js/plugins/textAngular/rangy-core.js:2923:14)
at Anonymous function (js/plugins/textAngular/rangy-core.js:415:21)
at Module.prototype.init (js/plugins/textAngular/rangy-core.js:387:13)
at init (js/plugins/textAngular/rangy-core.js:294:17)
at loadHandler (js/plugins/textAngular/rangy-core.js:3825:17)
Module 'SaveRestore' failed to load: Unable to get property 'isDirectionBackward' of undefined or null reference
TypeError: Unable to get property 'isDirectionBackward' of undefined or null reference
at Anonymous function (js/plugins/textAngular/rangy-selectionsaverestore.js:30:9)
at Anonymous function (js/plugins/textAngular/rangy-core.js:415:21)
at Module.prototype.init (js/plugins/textAngular/rangy-core.js:387:13)
at init (js/plugins/textAngular/rangy-core.js:294:17)
at loadHandler (js/plugins/textAngular/rangy-core.js:3825:17)
在范围初始化期间似乎发生此错误。
奇怪的是,TextAngular演示在Internet Explorer上运行良好。该演示与我的应用程序之间的区别在于,我使用的是未缩小的rangy库。最后,这些错误不会在Chrome或Firefox上发生。
尽管应用程序加载了(我认为上面的错误只是控制台中的警告),但是当我单击textAngular字段时,我看到以下错误:
对象不支持属性或方法“ getSelection”
文件:textAngular.js,行:693,列:4
我在textAngular或rangy github中找不到解决这些问题的任何东西。有人遇到过这些问题吗?
如果有帮助,我可以将链接发布到我们的应用程序。
谢谢!
最佳答案
看起来textAngular初始化范围选择太早了。我通过更新textAngular / dist / textAngular.js ln 2036解决了此问题,以等待onload之后再检查rangy库
window.onload = function() {
// Ensure that rangy and rangy.saveSelection exists on the window (global scope).
// TODO: Refactor so that the global scope is no longer used.
if(!window.rangy){
throw("rangy-core.js and rangy-selectionsaverestore.js are required for textAngular to work correctly, rangy-core is not yet loaded.");
}else{
window.rangy.init();
if(!window.rangy.saveSelection){
throw("rangy-selectionsaverestore.js is required for textAngular to work correctly.");
}
}
};