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.
Showing
3 changed files
with
8 additions
and
7 deletions
... | @@ -18,14 +18,13 @@ | ... | @@ -18,14 +18,13 @@ |
18 | 18 | ||
19 | Rivets.Binding = (function() { | 19 | Rivets.Binding = (function() { |
20 | 20 | ||
21 | function Binding(el, type, model, keypath, options, bindContext) { | 21 | function Binding(el, type, model, keypath, options) { |
22 | var identifier, regexp, value, _ref; | 22 | var identifier, regexp, value, _ref; |
23 | this.el = el; | 23 | this.el = el; |
24 | this.type = type; | 24 | this.type = type; |
25 | this.model = model; | 25 | this.model = model; |
26 | this.keypath = keypath; | 26 | this.keypath = keypath; |
27 | this.options = options != null ? options : {}; | 27 | this.options = options != null ? options : {}; |
28 | this.bindContext = bindContext; | ||
29 | this.unbind = __bind(this.unbind, this); | 28 | this.unbind = __bind(this.unbind, this); |
30 | 29 | ||
31 | this.bind = __bind(this.bind, this); | 30 | this.bind = __bind(this.bind, this); |
... | @@ -268,6 +267,7 @@ | ... | @@ -268,6 +267,7 @@ |
268 | splitPath = path.split(/\.|:/); | 267 | splitPath = path.split(/\.|:/); |
269 | options.formatters = pipes; | 268 | options.formatters = pipes; |
270 | options.bypass = path.indexOf(':') !== -1; | 269 | options.bypass = path.indexOf(':') !== -1; |
270 | options.models = _this.models; | ||
271 | if (splitPath[0]) { | 271 | if (splitPath[0]) { |
272 | model = _this.models[splitPath.shift()]; | 272 | model = _this.models[splitPath.shift()]; |
273 | } else { | 273 | } else { |
... | @@ -279,7 +279,7 @@ | ... | @@ -279,7 +279,7 @@ |
279 | if (dependencies = context.shift()) { | 279 | if (dependencies = context.shift()) { |
280 | options.dependencies = dependencies.split(/\s+/); | 280 | options.dependencies = dependencies.split(/\s+/); |
281 | } | 281 | } |
282 | binding = new Rivets.Binding(node, type, model, keypath, options, _this.models); | 282 | binding = new Rivets.Binding(node, type, model, keypath, options); |
283 | binding.view = _this; | 283 | binding.view = _this; |
284 | _this.bindings.push(binding); | 284 | _this.bindings.push(binding); |
285 | } | 285 | } |
... | @@ -509,7 +509,7 @@ | ... | @@ -509,7 +509,7 @@ |
509 | if (this.currentListener) { | 509 | if (this.currentListener) { |
510 | unbindEvent(el, this.args[0], this.currentListener); | 510 | unbindEvent(el, this.args[0], this.currentListener); |
511 | } | 511 | } |
512 | return this.currentListener = bindEvent(el, this.args[0], value, this.model, this.bindContext); | 512 | return this.currentListener = bindEvent(el, this.args[0], value, this.model, this.options.bindContext); |
513 | } | 513 | } |
514 | }, | 514 | }, |
515 | "each-*": { | 515 | "each-*": { | ... | ... |
This diff is collapsed.
Click to expand it.
... | @@ -14,7 +14,7 @@ class Rivets.Binding | ... | @@ -14,7 +14,7 @@ class Rivets.Binding |
14 | # All information about the binding is passed into the constructor; the DOM | 14 | # All information about the binding is passed into the constructor; the DOM |
15 | # element, the type of binding, the model object and the keypath at which | 15 | # element, the type of binding, the model object and the keypath at which |
16 | # to listen for changes. | 16 | # to listen for changes. |
17 | constructor: (@el, @type, @model, @keypath, @options = {}, @bindContext) -> | 17 | constructor: (@el, @type, @model, @keypath, @options = {}) -> |
18 | unless @binder = Rivets.binders[type] | 18 | unless @binder = Rivets.binders[type] |
19 | for identifier, value of Rivets.binders | 19 | for identifier, value of Rivets.binders |
20 | if identifier isnt '*' and identifier.indexOf('*') isnt -1 | 20 | if identifier isnt '*' and identifier.indexOf('*') isnt -1 |
... | @@ -173,6 +173,7 @@ class Rivets.View | ... | @@ -173,6 +173,7 @@ class Rivets.View |
173 | splitPath = path.split /\.|:/ | 173 | splitPath = path.split /\.|:/ |
174 | options.formatters = pipes | 174 | options.formatters = pipes |
175 | options.bypass = path.indexOf(':') != -1 | 175 | options.bypass = path.indexOf(':') != -1 |
176 | options.models = @models | ||
176 | if splitPath[0] | 177 | if splitPath[0] |
177 | model = @models[splitPath.shift()] | 178 | model = @models[splitPath.shift()] |
178 | else | 179 | else |
... | @@ -184,7 +185,7 @@ class Rivets.View | ... | @@ -184,7 +185,7 @@ class Rivets.View |
184 | if dependencies = context.shift() | 185 | if dependencies = context.shift() |
185 | options.dependencies = dependencies.split /\s+/ | 186 | options.dependencies = dependencies.split /\s+/ |
186 | 187 | ||
187 | binding = new Rivets.Binding node, type, model, keypath, options, @models | 188 | binding = new Rivets.Binding node, type, model, keypath, options |
188 | binding.view = @ | 189 | binding.view = @ |
189 | 190 | ||
190 | @bindings.push binding | 191 | @bindings.push binding |
... | @@ -321,7 +322,7 @@ Rivets.binders = | ... | @@ -321,7 +322,7 @@ Rivets.binders = |
321 | function: true | 322 | function: true |
322 | routine: (el, value) -> | 323 | routine: (el, value) -> |
323 | unbindEvent el, @args[0], @currentListener if @currentListener | 324 | unbindEvent el, @args[0], @currentListener if @currentListener |
324 | @currentListener = bindEvent el, @args[0], value, @model, @bindContext | 325 | @currentListener = bindEvent el, @args[0], value, @model, @options.bindContext |
325 | 326 | ||
326 | "each-*": | 327 | "each-*": |
327 | block: true | 328 | block: true | ... | ... |
-
Please register or sign in to post a comment