ckeditor / ckeditor4

The best enterprise-grade WYSIWYG editor. Fully customizable with countless features and plugins.
https://ckeditor.com/ckeditor-4
Other
5.8k stars 2.48k forks source link

Occasional stack trace error: Cannot read property 'on' of undefined #3346

Open CExJTian opened 5 years ago

CExJTian commented 5 years ago

Hi there,

We are using ckeditor version 4.11.2 and noticed occasional stack trace in server log: TypeError: Cannot read property 'on' of undefined

It seems to be caused by following code in file ckeditor.js, line 351 - 352.

attachListener: function(a) {
    !this._.listeners && (this._.listeners = []);
    var b = Array.prototype.slice.call(arguments,
            1),
        b = a.on.apply(a, b);
    this._.listeners.push(b);
    return b
}

It would be great if it can be taken care of when a is undefined.

Thanks!

Type of report

Bug

Provide detailed reproduction steps (if any)

Expected result

No stack trace error

Actual result

TypeError: Cannot read property 'on' of undefined

Other details

Dumluregn commented 5 years ago

Hello, thanks for creating this issue, could you give us some more details like when this error occurs? And if it can be reproduced in the current version, i.e. 4.12.1?

aasiph commented 5 years ago

For me the bug appears in chrome when changing editor mode to source and setting new data with event.editor.setData

editor.on('beforeSetMode', function(event) {
            var commentData;
             if ( event.data == 'source' ) {
                commentData = smileyHandler(event.editor.getData(),true);
                event.editor.setData(commentData);
             } else {
                commentData = smileyHandler(event.editor.getData(),false);
                event.editor.setData(commentData);
             }
         });

You can go through link http://www.aiglemedia.com/php/ajaxguestbook/ to verify the problem. Just click on add entry button and you will get the editor instance.

Also i see network activity of loading contents.css when switching to WYSIWYG mode.

And yes it appears in version 4.12.1 also which i have right now tested on local machine.

Comandeer commented 5 years ago

It seems that the issue is connected with the fact that initialisation of iframe-based editable, provided by wysiwygarea plugin, is asynchronous and part of it tries to finish after changing mode and destroying the iframe.

GitLaser commented 2 years ago

I also encountered this problem. How can I solve it