The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Polymer js: binding event handlers Reply To: Polymer js: binding event handlers


Until now, I have made javascript modules that scan the document for particular data-* attributes and the augment/modify those elements in some way. For example, the first time I figured this out was when I used a data-xhr-get attribute to declaratively load content via ajax. I’ve used the concept to initialize slideshows, and do similar tasks.

This is entirely adaptable to creating templates/behaviors for custom elements. It would be a lot of work, “re-inventing” stuff that google/mozilla have already done, but it would also be lighter, have a wider browser compatibility, and be much more suited to being a minor “add-on” to sites… I would lose the shadow dom, but that’s only supported in Chrome ATM. Everywhere else, it polyfills with a light dom anyway.

I would not be re-creating <template> or document.register or HTML imports; I’d just use normal JS for templating, add behavior through event handlers, and use requirejs for loading/dependencies.

So, long story short, polymer is cool… but I think we still need to wait for real web components.