Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception on stopListening() of DOMEmitterMixin #5258

Closed
oskarwrobel opened this issue Sep 27, 2016 · 2 comments · Fixed by ckeditor/ckeditor5-ui#84
Closed

Exception on stopListening() of DOMEmitterMixin #5258

oskarwrobel opened this issue Sep 27, 2016 · 2 comments · Fixed by ckeditor/ckeditor5-ui#84
Assignees
Labels
package:ui type:bug This issue reports a buggy (incorrect) behavior.
Milestone

Comments

@oskarwrobel
Copy link
Contributor

How to reproduce:

const emitter = Object.create( DOMEmitterMixin );

emitter.listenTo( element, 'someEvent', callback );
emitter.stopListening( element, 'someEvent', callback );

emitter.stopListening(); // TypeError: Cannot read property 'removeListener' of undefined.

This works fine:

const emitter = Object.create( DOMEmitterMixin );

emitter.listenTo( element, 'someEvent', callback );
emitter.stopListening( element, 'someEvent' ); // Without callback

emitter.stopListening();
@Reinmar
Copy link
Member

Reinmar commented Sep 27, 2016

This may be needed for #114.

@oskarwrobel
Copy link
Contributor Author

This is because parent EmitterMixin.off( event, callback ) removes only specified callback from callbacks array, and keeps event object in memory even if callbacks array is empty (is it expected?).

We can easily fix it by adding condition which prevent from removing non existing listener here or we can consider to improve EmitterMixin.off() to remove event from emitter when callbacks array is empty.

@mlewand mlewand transferred this issue from ckeditor/ckeditor5-ui Oct 9, 2019
@mlewand mlewand added this to the iteration 3 milestone Oct 9, 2019
@mlewand mlewand added status:confirmed type:bug This issue reports a buggy (incorrect) behavior. package:ui labels Oct 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package:ui type:bug This issue reports a buggy (incorrect) behavior.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants