Skip to content
This repository was archived by the owner on May 19, 2019. It is now read-only.

Commit 1f22fc8

Browse files
committed
fixed bug with removing change listener of proxied prop
1 parent 14dfeaa commit 1f22fc8

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

lib/utils.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,12 +173,13 @@ export function _createProperty(initValue) {
173173
prop.addChangeListener = toProp.addChangeListener;
174174
prop.emitChange = toProp.emitChange;
175175
_each(emitter.listeners('change'), cb => toProp.addChangeListener(cb));
176-
emitter = null;
176+
emitter = toProp.__emitter;
177177
store = null;
178178
};
179179

180180
prop.version = ++_propertyVersionId;
181181
prop.isProperty = true;
182+
prop.__emitter = emitter;
182183
return prop;
183184
}
184185

test/both/utils.test.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ describe('Utils', function () {
111111
var cb = sinon.spy();
112112
const propA = utils._createProperty('val');
113113
const toPropB = utils._createProperty('val2');
114-
propA.addChangeListener(cb);
114+
const stopper = propA.addChangeListener(cb);
115115
propA.proxyTo(toPropB);
116116
propA().should.be.equal('val2');
117117
toPropB().should.be.equal('val2');
@@ -122,6 +122,10 @@ describe('Utils', function () {
122122
toPropB('val3');
123123
cb.should.have.callCount(1);
124124
toPropB().should.be.equal('val3');
125+
stopper();
126+
toPropB('val4');
127+
cb.should.have.callCount(1);
128+
toPropB().should.be.equal('val4');
125129
});
126130
});
127131

0 commit comments

Comments
 (0)