51018f8d by Michael Richards

Clean up the reverse formatter loop in publish and remove the value condition at…

… the end. [Closes #97]
1 parent babbf49a
......@@ -70,18 +70,15 @@ class Rivets.Binding
# Publishes the value currently set on the input element back to the model.
publish: =>
value = getInputValue @el
if @formatters
i = @formatters.length-1
while(i > -1)
formatter = @formatters[i]
args = formatter.split /\s+/
id = args.shift()
# only re-assign if there is a two-way formatter.
if Rivets.formatters[id] and Rivets.formatters[id].publish
value = Rivets.formatters[id].publish value, args...
i--
if(value)
Rivets.config.adapter.publish @model, @keypath, value
for formatter in @formatters.slice(0).reverse()
args = formatter.split /\s+/
id = args.shift()
if Rivets.formatters[id]?.publish
value = Rivets.formatters[id].publish value, args...
Rivets.config.adapter.publish @model, @keypath, value
# Subscribes to the model for changes at the specified keypath. Bi-directional
# routines will also listen for changes on the element to propagate them back
......