Opened 11 years ago
Closed 11 years ago
#11400 closed Bug (fixed)
removeAllListeners does not remove listeners completely
Reported by: | Piotr Jasiun | Owned by: | Piotr Jasiun |
---|---|---|---|
Priority: | Normal | Milestone: | CKEditor 4.3.3 |
Component: | General | Version: | |
Keywords: | Cc: |
Description
var a = CKEDITOR.document.getById( 'a' ); a.on( 'click', function( evt ) { console.log( 'clicked' ); } ); a.removeAllListeners(); a.fire( 'click' ); //get 'clicked' on the console.
After removeAllListeners
indeed it is not possible to fire click event by clicking on the link but I can still call it by code (fire()
).
See attached file.
Attachments (1)
Change History (18)
Changed 11 years ago by
Attachment: | removeAllListeners.html added |
---|
comment:1 Changed 11 years ago by
Milestone: | → CKEditor 4.3.3 |
---|---|
Status: | new → pending |
comment:2 Changed 11 years ago by
Summary: | removeAllListeners does not block 'fire' → removeAllListeners does not remove listeners completely |
---|
comment:3 Changed 11 years ago by
Because we fire native events often in tests, we should make removeAllListeners
works the same way for browser events and fire
method. Otherwise editor in tests may works differently than in browser.
comment:4 Changed 11 years ago by
It will anyway ;) Firing mocked and not bubbling event is far from "natural". But I agree that less surprises is better.
comment:5 Changed 11 years ago by
Some time ago we noticed a weird issue #10365. It may be related to this ticket.
comment:6 Changed 11 years ago by
Ok, it struck me that those issues are indeed related and that domObj#removeAllListeners really should remove custom listeners as well. Explanation: http://dev.ckeditor.com/ticket/10365#comment:7
comment:7 Changed 11 years ago by
Status: | pending → confirmed |
---|
comment:8 Changed 11 years ago by
Owner: | set to Piotr Jasiun |
---|---|
Status: | confirmed → assigned |
comment:9 Changed 11 years ago by
PJ, please remember about checking when this issue was introduced. We should know if this wasn't intentional - e.g. it may help with avoiding permission denied errors on IEs, but then it would be a workaround rather than real fix, so it'd be still worth fixing this.
comment:10 follow-up: 12 Changed 11 years ago by
Last modification of this method was in 2010 and it wasn't connected with this issue, so I believe that it was there from the beginning. Anyway I will check if fix doesn't break anything on IE.
comment:11 Changed 11 years ago by
Status: | assigned → review |
---|
Fixed. Changes in t/11400 and corresponding test branch.
comment:12 Changed 11 years ago by
Replying to pjasiun:
Last modification of this method was in 2010 and it wasn't connected with this issue, so I believe that it was there from the beginning. Anyway I will check if fix doesn't break anything on IE.
I asked about git bisect search. The commit which changed this behaviour could be unrelated to this method, but still it might change something intentionally.
comment:13 Changed 11 years ago by
I can not do bisect, because this issue existed since this method was implemented. It was introduces in (git:b9bc4e8a). It had been created in domobject.js
before it was created in event.js
(git:2b3d24fb, 2012) what is partially the reason of this issue.
I mean now removeAllListeners
in event.js
works as I expect and remove listeners completely but the one in domobject.js
not, probably because no one was thinking about fire
method when he was working on it. Probably at the begging removeAllListeners
was just a DOM operation.
comment:14 Changed 11 years ago by
Status: | review → review_failed |
---|
IMO domObject#removeAllListeners
should call event.prototype.removeAllListeners
.
Except that everything is fine.
comment:15 Changed 11 years ago by
Status: | review_failed → review |
---|
I changed it and rebase both dev and tests on master.
comment:16 Changed 11 years ago by
Status: | review → review_passed |
---|
comment:17 Changed 11 years ago by
Resolution: | → fixed |
---|---|
Status: | review_passed → closed |
Fixed on master with git:ea89af0 on dev and e354684 on tests.
Indeed, it doesn't work as we would expect. However, it may work correctly, as expected by its author. If I understand correctly, this methods main goal is to free references to unblock memory. It has the same name as CKEDITOR.event's method, but it may have different application. Also note that theoretically no one should fire native events on DOM nodes - only browser should do that. However, we do that in some cases and that's ok. So most likely this method should also remove our listeners.