@@ -216,6 +216,12 @@ const ObservableMixin = {
unbindAttrs.forEach( attrName => {
const binding = boundAttributes.get( attrName );
+
+ // Nothing to do if the binding is not defined
+ if ( !binding ) {
+ return;
+ }
let toObservable, toAttr, toAttrs, toAttrBindings;
binding.to.forEach( to => {
@@ -739,6 +739,14 @@ describe( 'Observable', () => {
observable.unbind();
} );
+ it( 'should not fail when unbinding attribute that is not bound', () => {
+ const observable = new Observable();
+ observable.bind( 'foo' ).to( car, 'color' );
+ expect( () => observable.unbind( 'bar' ) ).to.not.throw();
+ } );
it( 'should throw when non-string attribute is passed', () => {
expect( () => {
car.unbind( new Date() );