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

Removing event handler causes error #2653

Closed
forrert opened this issue Nov 26, 2015 · 3 comments
Closed

Removing event handler causes error #2653

forrert opened this issue Nov 26, 2015 · 3 comments
Assignees

Comments

@forrert
Copy link

forrert commented Nov 26, 2015

I have a canvas with the following setup:

  • event handler 1 registered for 'object:modified' (could be any event, but the error happens as long as I'm working with handlers for the same event)
  • event handler 2 registered for 'object:modified'
  • event handler 1 unregisters event handler 2 when executing

When the event is triggered, handler 1 runs and removes handler 2. But fabric still wants to execute handler 2 but it has already been unregistered. The following error is printed to the console:
fabric.js:166 Uncaught TypeError: Cannot read property 'call' of undefined.

JS Fiddle

The error is not always a problem (in that it breaks the application), but it often does not finish the current action (e.g. resizing an object). I think it should be possible to remove handlers for an event, while that event is being handled.

@asturur
Copy link
Member

asturur commented Dec 26, 2015

http://jsfiddle.net/qny6q64w/2/

testing suggestion of @inssein about settimeout

@asturur asturur self-assigned this Dec 26, 2015
@asturur
Copy link
Member

asturur commented Apr 11, 2016

i wenr back on this issue. Regestiring the events in the correct order does not cause any problem.
http://jsfiddle.net/qny6q64w/3/
Do not really know if this is a bug or a misuse.

@asturur
Copy link
Member

asturur commented Apr 11, 2016

check on #2706

@asturur asturur closed this as completed Apr 11, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants