How to resolve "Attributes on element-name were data bound prior to Polymer upgrading the element?

二次信任 提交于 2019-12-28 17:42:11

问题


Since the latest version of Polymer (0.2.4) I get the following warning for a bunch of elements:

Attributes on us-requests-list were data bound prior to Polymer upgrading the element. This may result in incorrect binding types.

How do I resolve this warning? I've found the following issue on Github:

https://github.com/Polymer/polymer-dev/issues/20

Where they say:

Bindings made to an element before it is upgraded can end up being attribute bindings where property bindings were expected.

Generally this happens when a user has loaded element definitions out-of-order.

But what does that mean? For me the warning happens for elements that don't have any bindings or attributes at all.

Perhaps someone can explain to me what these words mean so I can be more specific about my question. It seems to me like the warnings happen at random, the only thing I can say about them is that they only happen on custom elements that are nested in other custom elements, but I don't think it happens for all my nested custom elements.


回答1:


When I've run into this in the past it's meant that I was defining my polymer elements in the wrong order. So if you define two elements my-elem1 and my-elem2 in one document, and my-elem2 depends on my-elem1, then the definition of my-elem1 should come first or you may see bugs like data not propagating as expected.




回答2:


You can also avoid the warning by adding the element on the Polymer.import's callback using the following code (instead of innerHTML =):

Polymer({
     ready: function() {
         Polymer.import(["urlToImport"],
                        this.elementImportComplete.bind(this));
     },
     elementImportComplete: function() {
         // Do it this way to avoid polymer's data binding warnings (and not 
         // by using innerHTML)
         var el = document.createElement(this.feedTypes[this.type]);
         this.$.container.appendChild(el);
     }
 });


来源:https://stackoverflow.com/questions/23870541/how-to-resolve-attributes-on-element-name-were-data-bound-prior-to-polymer-upgr

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!