Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 内部元素<;演示片段>;仅在IE11中未正确克隆/投影_Javascript_Polymer_Polymer 1.0 - Fatal编程技术网

Javascript 内部元素<;演示片段>;仅在IE11中未正确克隆/投影

Javascript 内部元素<;演示片段>;仅在IE11中未正确克隆/投影,javascript,polymer,polymer-1.0,Javascript,Polymer,Polymer 1.0,我认为IE11中的元素没有得到正确的预测。请看以下示例: <body unresolved> <p>If this demo works correctly, you should be able to see the message <code>"Hello there. Hola!"</code></p> <p> This works as expected in all browsers excep

我认为IE11中的元素没有得到正确的预测。请看以下示例:

<body unresolved>

  <p>If this demo works correctly, you should be able to see the message <code>"Hello there. Hola!"</code></p>

  <p>
    This works as expected in all browsers except Internet Explorer 11 (maybe 10, although I didn't test). The issue is that when I assign helloElement.value, helloElement is not the same element that is being appended to the dome after is projected inside
    the &lt;demo-snippet&gt;.
  </p>

  <demo-snippet>
    <template is="dom-bind">
      <hello-element></hello-element>

      <script>
        var helloElement = document.querySelector('hello-element');
        helloElement.value = 'Hola!';

        // Wait enough time to make sure demo-snipper is rendered properly
        setTimeout(function() {
          console.log(helloElement === document.querySelector('hello-element')) // this is true in all browsers. In IE11 is false.
        }, 3000)
      </script>
    </template>

  </demo-snippet>
</body>
除了在IE11中,在所有浏览器中,
helloElement.value
中指定的值都会复制到演示代码片段元素中的投影元素中。这意味着,如果您添加一个就绪处理程序

ready: function () {
   console.log(this.value) // --> 'Hola!' except IE11, that is ''
}
在将代码投影到内部时,这是聚合中的错误还是演示片段中的错误?或者什么时候连接到dom?我真的不知道:(


您可以在此Plunker中使用我的示例:

显然IE对此更为严格。您需要调用
元素.setAttribute
,而不仅仅是将其添加到对象中


这将确保polymer选择默认值作为属性。

显然IE对此更为严格。您需要调用
元素。setAttribute
,而不仅仅是将其添加到对象中


这将确保polymer选择默认值作为属性。

为什么不从标记中设置值?这是一个显示错误的示例。在我的实际代码中,我有一个大的数据数组,因此传入标记不是一个选项。但是谢谢。在这种情况下,您可以使用ajax从json文件中获取Irequest@jhuesos大量的数据可以传递到使用
dom repeat
元素(ppssibly嵌套)的模型中我有一个日历元素,它显示了一个完整的月份日历,详细列出了每天的约会列表。还有一个图表,显示了每天的约会列表有多满。所有的数据都在服务器的一个ajax请求中检索,然后全部添加到my elements属性中的一个对象中整个日历是使用单个对象的标记显示的。无法在一条注释中显示我的完整答案。document.querySelector()正在使用阴影dom,我认为根据多边形填充与否,其工作方式有所不同。如果您坚持在dom中工作(正如我在上一条注释中所说,这应该是不必要的)查看Polymer.dom()上的《聚合物开发者指南》操作例程。为什么您没有从标记中设置值?这是一个显示错误的示例。在我的实际代码中,我有一个大的数据数组,因此传入标记不是一个选项。但是谢谢。在这种情况下,您可以使用ajax从json文件中获取我request@jhuesos一个大的数据数组可以传递到一个模型中,然后使用
dom repeat
元素(ppssibly嵌套)我有一个日历元素,它显示了一个完整的月份日历,详细列出了每天的约会列表。还有一个图表,显示了每天的约会列表有多满。所有的数据都在服务器的一个ajax请求中检索,然后全部添加到my elements属性中的一个对象中整个日历是使用单个对象的标记显示的。无法在一条注释中显示我的完整答案。document.querySelector()正在使用阴影dom,我认为根据多边形填充与否,其工作方式有所不同。如果您坚持在dom中工作(正如我在上一条注释中所说,这应该是不必要的)请参阅Polymer.dom()操作例程中的Polymer developers指南。