Clean up the reverse formatter loop in publish and remove the value condition at…
… the end. [Closes #97]
Showing
1 changed file
with
5 additions
and
8 deletions
... | @@ -70,17 +70,14 @@ class Rivets.Binding | ... | @@ -70,17 +70,14 @@ class Rivets.Binding |
70 | # Publishes the value currently set on the input element back to the model. | 70 | # Publishes the value currently set on the input element back to the model. |
71 | publish: => | 71 | publish: => |
72 | value = getInputValue @el | 72 | value = getInputValue @el |
73 | if @formatters | 73 | |
74 | i = @formatters.length-1 | 74 | for formatter in @formatters.slice(0).reverse() |
75 | while(i > -1) | ||
76 | formatter = @formatters[i] | ||
77 | args = formatter.split /\s+/ | 75 | args = formatter.split /\s+/ |
78 | id = args.shift() | 76 | id = args.shift() |
79 | # only re-assign if there is a two-way formatter. | 77 | |
80 | if Rivets.formatters[id] and Rivets.formatters[id].publish | 78 | if Rivets.formatters[id]?.publish |
81 | value = Rivets.formatters[id].publish value, args... | 79 | value = Rivets.formatters[id].publish value, args... |
82 | i-- | 80 | |
83 | if(value) | ||
84 | Rivets.config.adapter.publish @model, @keypath, value | 81 | Rivets.config.adapter.publish @model, @keypath, value |
85 | 82 | ||
86 | # Subscribes to the model for changes at the specified keypath. Bi-directional | 83 | # Subscribes to the model for changes at the specified keypath. Bi-directional | ... | ... |
-
Please register or sign in to post a comment