Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

TemplateIterator does not share any APIs of NodeBinding #147

Open
jmesserly opened this issue Oct 28, 2013 · 1 comment
Open

TemplateIterator does not share any APIs of NodeBinding #147

jmesserly opened this issue Oct 28, 2013 · 1 comment
Assignees

Comments

@jmesserly
Copy link
Contributor

Not sure if this is a bug, or an intentional design tradeoff, but:

The NodeBinding type, typically accessible via Node.bindings has various APIs such as:

  • node
  • property
  • mode
  • path
  • value - getter/setter

In contrast TemplateElement.bind returns a TemplateIterator. It does not have any of those properties. Indeed, it cannot, as the same instance is shared by if/bind/repeat. (Is that for performance reasons?).

A few issues here:

  • what APIs are expected from Node.bindings?
  • should there be a NodeBinding that is created seperately for if/bind/repeat and points at the TemplateIterator? It could implement NodeBinding correctly.
  • alternatively, if it we must reuse TemplateIterator for performance, should I be able to use a type test to distinguish the two types of bindings? Currently NodeBinding and TemplateIterator names are both private (although the members are public via .bindings)
  • what is public API on TemplateIterator? Many of the methods/properties don't look public (you could violate the class invariants by calling methods at unexpected times.) Here's my guess on the public surface area... based on what would be useful reflection:
    • hasRepeat/hasBind/hasIf
    • repeatModel/bindModel/ifModel
    • repeatPath/bindPath/ifPath
    • close()/closed
@jmesserly
Copy link
Contributor Author

Another issue with this:

// Normally calling .close will only close that binding.
// However this will close the TemplateIterator, including the "bind" and "repeat"
template.bindings['if'].close(); 

@jmesserly jmesserly self-assigned this Aug 7, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant