googlearchive / TemplateBinding

TemplateBinding Prolyfill
290 stars 61 forks source link

Need mechanism for a template to upgrade custom elements before binding #88

Closed dfreedm closed 11 years ago

dfreedm commented 11 years ago

Example from StackOverflow: http://stackoverflow.com/posts/16821813/

If a <template> contains Custom Elements, bind can be called on those elements before they upgrade.

There is a currently a hack for Polymer to upgrade elements before MDV calls bind, but this only works if the template is inside a Polymer element. If a bare template is used, then the bindings are incorrect.

One possible solution is to reach up to the CustomElement registry and upgrade the template content after the WebComponentsReady event fires.

dfreedm commented 11 years ago

Fixed link: http://stackoverflow.com/questions/16817409/cannot-bind-to-custom-elements-attribute-placed-inside-a-template

sorvell commented 11 years ago

The first comment is not quite right. As long as polymer.js or platform.js is loaded, it's ensured that elements are upgrade before bind is called on them.

Under the custom elements polyfill, element definitions are ready only after the WebComponentsReady event fires. In this case, code was executing before this event.