Changes between Initial Version and Version 1 of Ticket #13122


Ignore:
Timestamp:
Mar 31, 2015, 9:39:29 AM (10 years ago)
Author:
Piotrek Koszuliński
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #13122

    • Property Status changed from new to confirmed
  • Ticket #13122 – Description

    initial v1  
    222. `CKEDITOR.instances.editor1.document.on( 'click', function() { console.log( 'click1' ) } );`
    333. Test that it works. OK.
    4 4. CKEDITOR.instances.editor1.setData( 'xxx' );
     44. `CKEDITOR.instances.editor1.setData( 'xxx' );`
    555. Test that the click listener no longer works. OK.
    666. `CKEDITOR.instances.editor1.document.on( 'click', function() { console.log( 'click2' ) } );`
    777. Test that it works. **NOK**.
    88
    9 In general - if listener to some event was attached before set data, then it will no longer work after setting data and it won't be possible to attach a new one.
     9In general - if listener to some event was attached before set data, then it will no longer work after setting data and it won't be possible to attach a new listener to that event.
    1010
    1111The reason is that setting data (unlike switching modes) keeps **the same document**, but writing to that document removes all its previous listeners.
    1212
    13 On every `domObject.on()` we push the listener to `domObject.getCustomData( '_' )` listeners repository and if a native listener has not been added yet we add it to the native element.
     13On every `domObject.on()` we push the listener to `domObject.getCustomData( '_' )` (the listeners repository) and if a native listener has not been added yet we add it to the native element. So there's only one native listener per event name.
    1414
    1515Since setting data keeps the same document, the custom data (our listeners repository) stays the same. But the native listeners are removed. This means that when trying to add a new listener editor thinks that a native listener was already added, because the listeners repository already contains an entry for that event.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy