283cd02f by Adam Heath

Reworked previous commit, so that the extra arg passed to new

Rivets.Binding() isn't needed.  I had mistakenly changed an external api,
which is generally frowned upon.
1 parent 019fa5c4
......@@ -18,14 +18,13 @@
Rivets.Binding = (function() {
function Binding(el, type, model, keypath, options, bindContext) {
function Binding(el, type, model, keypath, options) {
var identifier, regexp, value, _ref;
this.el = el;
this.type = type;
this.model = model;
this.keypath = keypath;
this.options = options != null ? options : {};
this.bindContext = bindContext;
this.unbind = __bind(this.unbind, this);
this.bind = __bind(this.bind, this);
......@@ -268,6 +267,7 @@
splitPath = path.split(/\.|:/);
options.formatters = pipes;
options.bypass = path.indexOf(':') !== -1;
options.models = _this.models;
if (splitPath[0]) {
model = _this.models[splitPath.shift()];
} else {
......@@ -279,7 +279,7 @@
if (dependencies = context.shift()) {
options.dependencies = dependencies.split(/\s+/);
}
binding = new Rivets.Binding(node, type, model, keypath, options, _this.models);
binding = new Rivets.Binding(node, type, model, keypath, options);
binding.view = _this;
_this.bindings.push(binding);
}
......@@ -509,7 +509,7 @@
if (this.currentListener) {
unbindEvent(el, this.args[0], this.currentListener);
}
return this.currentListener = bindEvent(el, this.args[0], value, this.model, this.bindContext);
return this.currentListener = bindEvent(el, this.args[0], value, this.model, this.options.bindContext);
}
},
"each-*": {
......
......@@ -14,7 +14,7 @@ class Rivets.Binding
# All information about the binding is passed into the constructor; the DOM
# element, the type of binding, the model object and the keypath at which
# to listen for changes.
constructor: (@el, @type, @model, @keypath, @options = {}, @bindContext) ->
constructor: (@el, @type, @model, @keypath, @options = {}) ->
unless @binder = Rivets.binders[type]
for identifier, value of Rivets.binders
if identifier isnt '*' and identifier.indexOf('*') isnt -1
......@@ -173,6 +173,7 @@ class Rivets.View
splitPath = path.split /\.|:/
options.formatters = pipes
options.bypass = path.indexOf(':') != -1
options.models = @models
if splitPath[0]
model = @models[splitPath.shift()]
else
......@@ -184,7 +185,7 @@ class Rivets.View
if dependencies = context.shift()
options.dependencies = dependencies.split /\s+/
binding = new Rivets.Binding node, type, model, keypath, options, @models
binding = new Rivets.Binding node, type, model, keypath, options
binding.view = @
@bindings.push binding
......@@ -321,7 +322,7 @@ Rivets.binders =
function: true
routine: (el, value) ->
unbindEvent el, @args[0], @currentListener if @currentListener
@currentListener = bindEvent el, @args[0], value, @model, @bindContext
@currentListener = bindEvent el, @args[0], value, @model, @options.bindContext
"each-*":
block: true
......