简体   繁体   English

铬铁形态的问题

[英]Problems with iron-form on chrome

I am trying to use iron-form but I can't access the non-native elements of the form on Chrome. 我正在尝试使用Iron-form,但是无法在Chrome上访问该表单的非本地元素。

<dom-module id="e404-view">
    <template>
        <style>
            :host {
                display: block;

                padding: 10px 20px;
            }

        </style>

        <form id="step1Form" is="iron-form">
            <input>
            <paper-input></paper-input>
        </form>

        You hit a 404. <a href="/home">Head back to home</a>
    </template>

    <script>
        Polymer({
            is: 'e404-view',

            ready: function () {
                var form = this.$.step1Form;
//                console.log(form.elements);
                for (var el, i = 0; el = form.elements[i], i < form.elements.length; i++) {
                    console.log(el);
                }
            }
        });
    </script>
</dom-module>

Here is a simple view which contains form. 这是一个包含表单的简单视图。 When I iterate through the form.elements on Chrome there is only one input in the array. 当我在Chrome上浏览form.elements时,数组中只有一个输入。 However this example works perfectly fine on Firefox. 但是,此示例在Firefox上运行良好。

I am building an app and the weird thing is that when I use the same view in different project everything works fine. 我正在构建一个应用程序,但奇怪的是,当我在不同的项目中使用相同的视图时,一切正常。 I think that there are some collisions in the app or something like that. 我认为应用程序中有一些冲突或类似的东西。 This view is shown through iron-pages in the app. 该视图通过应用程序中的铁页显示。 However I am not sure why it works on Firefox. 但是我不确定为什么它可以在Firefox上运行。

I can't seems to find out what's wrong and any advises or hints will be appreciated. 我似乎无法找出问题所在,任何建议或提示都将不胜感激。 If I won't solve the bug I'll probably remove the form and handle the validation myself. 如果我不能解决问题,我可能会删除表格并亲自处理验证。

Thanks in advance, Jan 预先感谢,扬

I found a solution. 我找到了解决方案。 The problem was caused by global Polymer settings which were located in the index.html. 该问题是由位于index.html中的全局Polymer设置引起的。

Here is the problematic part: 这是有问题的部分:

    window.Polymer = {
        dom: 'shadow',
        lazyRegister: true
    };

When I commented out the dom: 'shadow' setting, everything began working. 当我注释掉dom:“阴影”设置时,一切开始起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM