2016-02-26 56 views
0

當啓動Aurelia應用程序時,我們已經注意到IE11中真正奇怪的行爲。 只有在您第一次在新窗口/選項卡中啓動應用程序並且鼠標光標不在IE窗口區域(例如,程序從具有給定url的命令行運行 - 這對我們來說這是重要場景)時纔會發生。然後,應用程序停留在帶有靜態內容的index.html中,但沒有任何反應。 直到你將光標移動到窗口上...然後神奇的應用程序繼續沒有任何錯誤和任何問題。IE11承諾奇怪的行爲

只要我能調試,當腳本進入System.import('core-js')諾言時就會發生問題。它發生在或不使用藍鳥許諾。

這是來自「index.html」的正文。

<script src="jspm_packages/system.js"></script> 
<script src="config.js"></script> 
<script> 
    System.import('core-js').then(function() { 
    return System.import('webcomponents.js/MutationObserver'); 
    }).then(function() { 
    return System.import('aurelia-bootstrapper'); 
    }); 
</script> 

編輯:

我注意到,有什麼可以幫助就是把承諾與超時(至少1000毫秒)。如果有更好的解決方案存在,你有什麼想法嗎?

<script src="jspm_packages/npm/[email protected]/js/browser/bluebird.js"></script> 
<script src="jspm_packages/system.js"></script> 
<script src="config.js"></script> 
<script> 
    // IE11 hack for mutation observer/promises error 
    var promise = new Promise(function (resolve) { 
     window.setTimeout(
      function() { 
       resolve(); 
      }, 1000); 
    }); 

    System.import('core-js').then(function() { 
     return System.import('webcomponents.js/MutationObserver'); 
    }).then(function() { 
     return System.import('aurelia-bootstrapper'); 
    }); 
</script> 
+0

聽起來像一個討厭的小錯誤。您可以通過觸發鼠標懸停事件(例如在頁面加載時)強制進行初始化,但請注意不要觸發兩次(安全性可能已經存在,但您需要確保)。 –

回答

0

以下是由IE11突變觀察者行爲w.r.t調度引起的錯誤的解決方法。此解決方法適用於藍鳥,但不適用於其他polyfills:

// use timers for scheduling 
Promise.setScheduler(function(fn) { setTimeout(fn); }); 
+0

謝謝你的解決方案,但是在這種情況下它不會工作:(看起來system.js正在改變Promise對象,因爲在導入system.js腳本之後Promise.setScheduler函數變得未定義,我需要在導入後使用promise這個軟件包,你有什麼想法我該如何解決這個問題? – Saadh

+0

是的,手動導入藍鳥作爲諾言。 –

+0

我不確定你的意思,請你提供一些例子嗎? – Saadh