cd102889 by Michael Richards

Make sure that we unsubscribe the whole keypath observer when unbinding a binding for good. [#223]

1 parent f35223d4
......@@ -107,7 +107,10 @@ class Rivets.Binding
# Unsubscribes from the model and the element.
unbind: (silent = false) =>
@binder.unbind?.call @, @el unless silent
unless silent
@binder.unbind?.call @, @el
@observer.unobserve()
@view.adapters[@key.interface].unsubscribe(@model, @key.path, @sync) if @key
if @dependencies.length
......
......@@ -39,3 +39,8 @@ class KeypathObserver
current = @view.adapters[token.interface].read current, token.path
current
unobserve: =>
for token, index in @tokens
if obj = @objectPath[index]
@view.adapters[token.interface].unsubscribe obj, token.path, @update
......