2015-03-03 20 views
1

我遇到了意想不到的問題。聚合物就地燃燒在IE11上,但不在Firefox或Chrome上

我有兩頁聚合物。兩者都在IE11上運行得很好,完全沒有問題(性能下降除外)。 現在,在Firefox和Chrome上,其中一個工作不正常,從未激發聚合物就緒,另一個工作正常。 如果有的話,人們會認爲IE將是一個有問題的人。

與此相關的非火行爲,唯一的聚合物分子本頁顯示FF或Chrome是主要的工具欄,並將其內部的東西,僅此而已。 我只是不知道下一步該怎麼做。

以下是標題。第一個來自工作到處的頁面,沒有問題。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head id="Head1" runat="server"> 
    <meta charset="utf-8" /> 
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> 
    <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes" /> 
    <title>N-Adviser</title> 
    [... a bunch of element imports ...] 
    <script src="components/webcomponentsjs/webcomponents.js"></script> 
    <style shim-shadowdom> 
     [...some styling...] 
    </style> 
    <script src="http://code.jquery.com/jquery-1.7.js" type="text/javascript"></script> 
</head> 

而這裏的壞

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head id="headPortal" runat="server"> 
    <meta charset="utf-8" /> 
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> 
    <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes" /> 
    <title>Portal</title> 
    <link rel="import" href="components/font-roboto/roboto.html" /> 
    <link rel="import" href="components/polymer/polymer.html" /> 
    [...a bunch of element imports...] 
    <link type="text/css" rel="stylesheet" href="Styles/LoginStyle.css" shim-shadowdom /> 
    <script src="components/webcomponentsjs/webcomponents.js"></script> 
    <style></style> 
    <script src="http://code.jquery.com/jquery-1.7.js" type="text/javascript"></script> 
</head> 

無法看到任何差別,除了一個事實,即他們中的一個外部文件,這不應該的問題進口的CSS。

他們都有自己的JavaScript代碼,所有的HTML

<script type="text/javascript"> 
    $(document).ready(function() { 
     alert("docready"); 
    }); 
    window.addEventListener('polymer-ready', function (e) { 
     alert("polready"); 
    [...] 
</script> 

兩個火document.ready後,但只有第一個觸發聚合物就緒。有什麼想法嗎?

回答

2

webcomponents.js應該在html導入之前加載。嘗試將該腳本標記移到所有導入之上(另請參閱https://www.polymer-project.org/docs/start/creatingelements.html)。這應該是全部。

我想我可以解釋這種奇怪的行爲。可能在導入文件的第一個例子中沒有聚合物特定功能,第二個例子中有(注意Polymer!= web組件,webcomponents.js包含聚合物特定功能)。由於IE11本身不支持Web組件,它會跳過html導入標記(它不知道它們),然後聚合物的polyfill將在加載webcomponents.js並加載它們之後掃描文檔(因爲這是polyfill中的函數) 。

由於Chrome和FF確實有網絡組件支持他們「看」的HTML進口都尚未加載的webcomponents.js和聚合物的功能之前。因此它不起作用。

+0

我以爲我已經測試過導入的每一個訂單,但又試着改變webcomponents.js。仍然不能正常工作,聚合物不能正常工作:/ 另外,我沒有在我的問題上說過,但是工作的頁面比另一個複雜得多,並且輸入了所有「壞」的東西,還有其他許多人。我會記住你的解釋,因爲它可能是有用的,但不是在這種情況下。 – Iskalla 2015-03-04 07:48:57

+0

對不起,我的意思是你的解釋非常有意義,仍然不能解決問題 – Iskalla 2015-03-04 07:56:59

相關問題