googlearchive / TemplateBinding

TemplateBinding Prolyfill
290 stars 61 forks source link

[v2] missing information for delegate() (?) #26

Closed sjmiles closed 11 years ago

sjmiles commented 11 years ago

Under v2, Toolkit binds a shadow-root to a model like so:

HTMLTemplateElement.bindTree(inRoot, model, delegate);

Now, imagine a shadow root like this:

<shadow-root>
  <g-icon src="{{iconSrc}}"></g-icon>
</shadow-root>

The owner of root needs to process src="{{iconSrc}}" as a custom property binding. To do that, the delegate must have four pieces of information: the target node (g-icon), the target attribute ('src'), the model (model), and the content string ('iconSrc').

Currently the delegate currently only receives model, and 'iconSrc' as inputs.

bindOrDelegate has the other values available, so I monkey-patched them in as arguments to delegate, and it worked a treat. I.e.

delegateBinding = delegate(path, model, node, name);

Btw, overall, the new system is a big advance as it let's us remove a ton of code.

sjmiles commented 11 years ago

This turns out to be me trying to invert the control pattern.

If we make g-icon responsible for binding instead of the controller, the problem goes away, and we are no longer absuing delegate.