This also explains why having Polymer({}) calls in JavaScript doesn't work
as expected if the JavaScript is deferred, and you have other Polymer({})
calls in sync scripts (or HTML).Sites like jsbin.com have this trap: http://jsbin.com/nalasajedu/1/edit?html,js,output On Wed, Aug 19, 2015 at 2:43 PM, Eric Bidelman <[email protected]> wrote: > You've stumbled onto the awesome sauce that is custom element upgrades :) > > > http://www.html5rocks.com/en/tutorials/webcomponents/customelements/#upgrades > > Polymer() is simply a convenience + features wrapper for > document.registerElement(). You can have <your-element> > declared on the page, but until it's registered, it won't have of any of > it's special features minted or shady/shadow dom created. > > On Wed, Aug 19, 2015 at 1:19 PM <[email protected]> wrote: > >> I just realized that the Polymer(...) declaration in a custom element >> can be asynchronous. In other words, the following works precisely as >> expected: >> >> >> <dom-module id="foo"> >> ... >> </dom-module> >> <script> >> window.setTimeout(function() { >> Polymer({ >> is: "foo", >> ... >> }); >> }, 5000); >> </script> >> >> >> All the foo elements are invisible until 5 seconds later, when they pop >> into place! This means I could enclose it in -- say -- a RequireJS module. >> Very nice work! >> >> Ihab >> >> -- >> Ihab A.B. Awad, Palo Alto, CA >> >> Follow Polymer on Google+: plus.google.com/107187849809354688692 >> --- >> You received this message because you are subscribed to the Google Groups >> "Polymer" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/polymer-dev/CAG7xX7oDPjqmCKEg1vaoD%3D-xctRGP2zmXZN03J6LY9W5wAf0vQ%40mail.gmail.com >> <https://groups.google.com/d/msgid/polymer-dev/CAG7xX7oDPjqmCKEg1vaoD%3D-xctRGP2zmXZN03J6LY9W5wAf0vQ%40mail.gmail.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > Follow Polymer on Google+: plus.google.com/107187849809354688692 > --- > You received this message because you are subscribed to the Google Groups > "Polymer" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/polymer-dev/CACGqRCBTT11ru9H6OCsqGrUTdJtj8Y-0vz4-wesfiihF-sxsKg%40mail.gmail.com > <https://groups.google.com/d/msgid/polymer-dev/CACGqRCBTT11ru9H6OCsqGrUTdJtj8Y-0vz4-wesfiihF-sxsKg%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > Follow Polymer on Google+: plus.google.com/107187849809354688692 --- You received this message because you are subscribed to the Google Groups "Polymer" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/polymer-dev/CACi5S_0WiSnZ-XtuReRdpHQwUfD7Hd2Z4SZ7b3YYeza378U7hQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
