2017-03-01 10 views
1

Googleが提供するサンプルコードをhttps://www.polymer-project.org/1.0/start/first-element/introで試してみます。ポリマーサンプルコードがFirefoxで動作しない

これは私がこれまで持っているものです。

のindex.html:

<!DOCTYPE html>                           
<html lang="en">                           
    <head>                             
    <meta charset="utf8">                         
    <meta http-equiv="X-UA-Compatible" content="IE=edge">                 
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">    
    <script src="https://polygit.org/components/webcomponentsjs/webcomponents-lite.js"></script>       
    <link href="/my_components/icon-toggle-demo.html" rel="import">              
    </head>                             
    <body>                             
    <icon-toggle-demo toggle-icon="star"></icon-toggle-demo>                
    </body>                             
</html> 

アイコントグルdemo.html:

<link rel="import" href="https://polygit.org/components/polymer/polymer.html">            
<link rel="import" href="https://polygit.org/components/iron-icons/iron-icons.html">           
<link rel="import" href="icon-toggle.html">                     


<dom-module id="icon-toggle-demo">                       
    <template>                             
    <style>                             
     :host {                            
     font-family: sans-serif;                        
     };                              
    </style>                             

    <h3>Statically-configured icon-toggles</h3>                    

    <icon-toggle toggle-icon="star"></icon-toggle>                   
    <icon-toggle toggle-icon="star" pressed></icon-toggle>                 

    <h3>Data-bound icon-toggle</h3>                       

    <!-- use a computed binding to generate the message -->                 
    <div><span>[[message(isFav)]]</span></div>                    

    <!-- curly brackets ({{}}} allow two-way binding -->                  
    <icon-toggle toggle-icon="favorite" pressed="{{isFav}}"></icon-toggle>             
    </template>                            

    <script>                             
    Polymer({                            
     is: "icon-toggle-demo",                        
     message: function(fav) {                        
     if (fav) {                           
      return "You really like me!";                      
     } else {                            
      return "Do you like me?";                       
     }                             
     }                              
    });                              
    </script>                             
</dom-module> 

アイコン-toggle.html:

<link rel="import" href="https://polygit.org/components/polymer/polymer.html">            
<link rel="import" href="https://polygit.org/components/iron-icon/iron-icon.html">           

<dom-module id="icon-toggle">                        

    <template>                             

    <style>                             
     /* local DOM styles go here */                       
     :host {                            
     display: inline-block;                        
     }                              

     iron-icon {                           
     fill: rgba(0,0,0,0);                         
     stroke: currentcolor;                        
     }                              
     :host([pressed]) iron-icon {                       
     fill: currentcolor;                         
     }                              

    </style>                             

    <!-- local DOM goes here -->                        
    <!-- <span>Not much here yet.</span> -->                     
    <!-- <iron-icon icon="polymer"> -->                      
    <iron-icon icon="[[toggleIcon]]">                      
    </iron-icon>                            
    </template>                            

    <script>                             
    Polymer({                             
    is: 'icon-toggle',                          
    properties: {                           
     toggleIcon: String,                         
     pressed: {                            
     type: Boolean,                          
     value: false,                          
     notify: true,                          
     reflectToAttribute: true                        
     }                              
    }, 
    listeners: {                           
     'tap': 'toggle'                          
    },                             
    toggle: function() {                         
     this.pressed = !this.pressed;                      
    }                              
    });                              
    </script>                            

</dom-module> 

コードはchrome buでうまく動作しますt FFに次のエラーが表示されます。

TypeError: document.registerElement is not a function 

すでにpolyfillが含まれています。他に何か不足していますか?

答えて

1

あなたは何も間違っていません。 index.htmlファイルの次の行は、デフォルトで、Webコンポーネントpolyfillの最新バージョン(v1.0.0-rc.1)になります。

<script src="https://polygit.org/components/webcomponentsjs/webcomponents-lite.js"></script> 

現在のバージョンのFirefoxにはバグがあるようです。同様のエラーはPolymer文書hereにリンクされているPlunkerでも見ることができます。これはポリマーチームによってうまくいけばうまくいきます。

今すぐ修正するには、古いバージョンを明示的に使用できます。例えば。

<script src="https://cdn.rawgit.com/webcomponents/webcomponentsjs/v0.7.24/webcomponents-lite.js"></script> 
+0

Githubで[問題](https://github.com/webcomponents/webcomponentsjs/issues/699)を開きました。 – Maria

1

WebComponents v1.0.0 +は、Polymer 2.0でのみ使用してください。バージョン^ 0.7.24をポリマー1で使用してください。

関連する問題