You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Observers internally use colon in the eventName and assume there is only one colon when a split(':') operation is performed in activateObserver. By registering an observer with a key name that contains colons, you can break Ember's assumption.
🔬 Minimal Reproduction
emberObj.addObserver('key:with:colons',()=>{console.log('I will never fire');});emberObj.set('key:with:colons','foo');
😕 Actual Behavior
The callback method never fires
🤔 Expected Behavior
The callback method fires
🌍 Environment
Ember: - 3.16.10
Node.js/npm: - node 10.23.0, npm 6.13.7
OS: - mac mojave 10.14.6
Browser: - chrome 87.0.4280.141
➕ Additional Context
The issue appears to be in the activateObserver function
functionactivateObserver(target,eventName,sync=false){varactiveObservers=getOrCreateActiveObserversFor(target,sync);if(activeObservers.has(eventName)){activeObservers.get(eventName).count++;}else{// the following line assumes there are no colons in the user-specified portion of the eventNamevar[path]=eventName.split(':');vartag=(0,_reference.combine)(getChainTagsForKey(target,path));activeObservers.set(eventName,{count: 1,
path,
tag,lastRevision: (0,_reference.value)(tag),suspended: false});}}
One gross fix would be something like
// split the string on colon, drop the final value, re-join on colonvarpath=eventName.split(':').slice(0,-1).join(':')
But someone with a deeper understanding of the observer code may know of something more elegant
The text was updated successfully, but these errors were encountered:
🐞 Describe the Bug
Observers internally use colon in the
eventName
and assume there is only one colon when asplit(':')
operation is performed inactivateObserver
. By registering an observer with a key name that contains colons, you can break Ember's assumption.🔬 Minimal Reproduction
😕 Actual Behavior
The callback method never fires
🤔 Expected Behavior
The callback method fires
🌍 Environment
➕ Additional Context
The issue appears to be in the
activateObserver
functionOne gross fix would be something like
But someone with a deeper understanding of the observer code may know of something more elegant
The text was updated successfully, but these errors were encountered: