AmpersandJS / ampersand-state

Core state management object.
MIT License
141 stars 75 forks source link

Fix stopListening when changing a prop of type "state" #234

Closed janpaul123 closed 8 years ago

janpaul123 commented 8 years ago

We used to just call this.stopListening on a property of type "state" whenever we changed it out for some other object. However, this also unbinds any other listeners on that object, unexpectedly.

Instead, we should keep a reference to the handler, which we do by changing _getEventBubblingHandler into _getCachedEventBubblingHandler and saving it for the propertyName. This way, we can unbind just the handler we just set, and leave other event listeners untouched.

(Tests pending, want to get this out quickly.)

janpaul123 commented 8 years ago

Whoops, this one should have been for our own fork until we have written tests for it.

coveralls commented 8 years ago

Coverage Status

Coverage increased (+0.02%) to 97.739% when pulling d9fd4dba3a0c49b5715870c74731e732aac56a76 on remix:fix-stoplistening into 7021f00b35cf0d328749d0898e90f9670691a890 on AmpersandJS:master.