googlearchive / TemplateBinding

TemplateBinding Prolyfill
290 stars 61 forks source link

prepareBinding -- redundant "name" argument passed to returned function #146

Closed jmesserly closed 10 years ago

jmesserly commented 10 years ago

prepareBinding takes (path, name, node), and returns a function that takes (model, name, node), for example:

  function prepareBinding(expressionText, name, node) {
    var expression;
    try {
      expression = getExpression(expressionText);
     ...
    } catch (ex) {
      ...
    }

    return function(model, name, node) {
      var binding = expression.getBinding(model);
      ...
      return binding
    }
  }

As far as I can tell, "name" is always the same to the inner and outer function, so it could be handled easily by the closure. (In contrast "node" is not the same. It starts as a node in the template, but it becomes the node from the instance).

Alternatively -- if the goal is to help people avoid the closure, then shouldn't "path" be passed in again too?

arv commented 10 years ago

Seems fine to remove to me.

rafaelw commented 10 years ago

Done. https://github.com/Polymer/polymer-expressions/commit/c62e1ae, https://github.com/Polymer/TemplateBinding/commit/8028ba8b0e93da62258f7c873430c37b184adc24