I haven't tried to use TemplateBinding standalone, so I can't really address your first set of issues, but with regard to Intuitiveness:
1. Where does the shadow dom start? Is that what the template element does? Is template synomonous with shadow dom?
2. What is the template element for? Can I have multiple template elements at that level?
Yes, when your element is instantiated, Polymer stamps out the contents of the first
<template> tag inside your
<polymer-element> into the Shadow DOM. That's stated
here. This means that re #2, you can place as many template tags as you want inside your
<polymer-element>, but Polymer will only stamp out the first one for you. You could very well add additional template tags with IDs and stamp them out manually from your lifecycle callback code.
3. How does it know which script tag is the polymer element definition script tag? Does it care? Why is that script tag inside the polymer element? Is it in the shadow dom? or the global scope? It appears the global scope? In which case, why is it inside the <polymer-element> element?
It doesn't know. That script tag is just a plain ol' script tag (in the global scope, like you noticed). It's usually placed inside the
<polymer-element> for
convenience, but it could very well be
outside or even in a
separate file. Polymer just waits until it's seen a
<polymer-element name="my-name"> tag and a
Polymer('my-name', {}) call from anywhere then defines a new element using the contents of both.
4. What if I don't want to use shadow dom for my custom element? But I still want the model change listeners, the auto binding, etc?
There used to be a
lightdom attribute for this, but it was removed, probably for reasons stated
here. You could probably find a way to use Polymer's
auto-binding template inside your custom element. If not, you can still create your own custom elements without Polymer and directly use the
observe-js polyfill and
TemplateBinding library to get what you want (although you did mention that TemplateBinding doesn't seem to be the easiest thing to use as a standalone library).
5. The this.$.elementID helper doesn't seem to find dynamicly created elements (e.g. an element created from the results of an ajax request), it should just be removed imho
This is probably the case first and foremost for performance reasons, but it also makes sense in terms of Polymer's vision. Instead of adding an element to your Shadow DOM imperatively (using JavaScript), Polymer gives your markup
superpowers so it can represent the full set of states of your element. In the rare case that you still need access to dynamically generated elements, you can still use vanilla javascript:
this.$.myStaticNode.querySelector('.dynamicallyGeneratedContent').
6. How come when I include jQuery inside the template, then I create another script to use jQuery, it can't find jQuery? Nor can I access it via this.jQuery or any other way I could think of, E.g.
Not sure exactly what's going on here, but it looks like
<script> tags inside
<polymer-element> templates are loaded asynchronously ($ is available when the page finishes loading, just not when your
<script> tag runs), but the standard practice is for a
<polymer-element> to specify its external dependencies
outside its element definition, which makes your code
work fine. (You could even create an HTML Import
for your external dependency and Polymer would automatically dedupe that resource, preventing it from being loaded multiple times by different components)