Ticket #8545 (confirmed Bug)

Opened 3 years ago

Last modified 21 months ago

Uncaught JS errors when destroying editor/textarea before fully loaded

Reported by: Ildefonse Owned by:
Priority: Normal Milestone:
Component: General Version: 3.0
Keywords: Cc: chris.ingham@…

Description

  • Issue a jQuery adapter .ckeditor() call on a dynamically created element
  • Destroy the element (e.g. popup, close again, remove from DOM), before the ckeditor() has fully loaded/initialized
  • Several errors occur, depending on browser.

Chrome says: Uncaught TypeError: Cannot call method 'setHtml' of null (ckeditor.js, line 127) Firefox says: p is null [Break On This Error] (function(){var m;j.add('editingblock'...e==1&&D.getName() in f.$removeEmpty;

Of course, this only happens when you refresh/empty cache, and the ckeditor resources are not loaded yet. When they are in browser cache, the editor loads too quickly for this to be an issue.

It would be nice however, if there were some (better) checks in place, making sure that the elements are still there. If not, simply abort the loading process gracefully.

Let me know if you need more details.

Attachments

3 files.zip (4.3 KB) - added by j.swiderski 3 years ago.

Change History

comment:1 Changed 3 years ago by j.swiderski

  • Status changed from new to pending
  • Version 3.6.2 deleted

@Ildefonse you think it would be possible to provide a reduced test-case file showing the problem?

comment:2 Changed 3 years ago by Ildefonse

I will try to make a jsfiddle yes.

comment:3 Changed 3 years ago by j.swiderski

Ok. I'm waiting for your feedback.

comment:4 Changed 3 years ago by j.swiderski

@Ildefonse any luck with the TC?

comment:5 Changed 3 years ago by Ildefonse

Sorry didn't have time yet... so much work. But i *will* try to do it either this or next week.

comment:6 Changed 3 years ago by j.swiderski

  • Status changed from pending to confirmed
  • Version set to 3.0

I'm attaching 3 files. Please put them in _samples folder.

  1. CKEditor JQuery dialog

To Reproduce

  • Click on Create Instance button
  • Before editor gets fully loaded click X on the dialog. This requires you to feel the right moment.
  • I have managed to reproduce the issue with this sample from CKEditor 3.3.1
  1. CKEditor in YUI dialog - provided by @mrfr0g

To Reproduce

  • Click on "Show (CRTL+Y)" button
  • Before editor gets fully loaded press ESCAPE key. This also requires you to feel the right moment.
  • I have managed to reproduce the issue with this sample from CKEditor 3.3.2
  • I'm not sure if this sample is valid as when you remove the line YAHOO.example.container.panel1.destroy(); you get no errors.
  1. Perhaps invalid sample but easiest way to reproduce.

To Reproduce

  • Load the page in a browser
  • I have managed to reproduce the issue with this sample from CKEditor 3.0

JS Error returned by samples:

Errors for 1 & 2 are only thrown when ckeditor.js is used.

Message: i.contentWindow is null
Line: 20
URI: ckeditor.js

2. Message: i.contentWindow is null
Line: 149
URI: ckeditor.js

3. Message: this.toolbox is undefined
Line: 387
URI: /ckeditor/_source/plugins/toolbar/plugin.js

Changed 3 years ago by j.swiderski

comment:7 Changed 3 years ago by wwalc

I'm pasting the comment that rkoberg was trying to add:

This error still occurs in the released version and the nightly build as of today. It occurs when trying to hide an existing editor/textarea. It also occurs if I set the textarea editor to position:absolute;top-1000. Any workaround or fix? Where is the straight source to use to debug? I can only find the minified/packed version.

( Here is a slight fix, that gets you a little further, but then there is another error (L is null, in FF): http://www.lukerodgers.ca/2011/07/bug-in-ckeditor-version-3-6-1-revision-7072/ )

In firefox you get the error:

p is null

init(n="wysiwyg")ckeditor.js (line 128)
init()ckeditor.js (line 128)
getUrl(o=Object { _={...}, elementMode=1, element={...}, more...}, p=undefined, q=function(), r=function())ckeditor.js (line 6)
getUrl(h="uiReady", i=undefined, j=Object { _={...}, elementMode=1, element={...}, more...})ckeditor.js (line 6)
hasListeners(b="uiReady", c=undefined)ckeditor.js (line 7)
getUrl(d="uiReady", e=undefined, f=Object { _={...}, elementMode=1, element={...}, more...})ckeditor.js (line 6)
hasListeners(b="uiReady", c=undefined)ckeditor.js (line 7)
build(o=Object { _={...}, elementMode=1, element={...}, more...}, p=undefined)ckeditor.js (line 149)
fn()ckeditor.js (line 25)
detect(u=[], v=[])
...more

In Chrome you get the error:

Uncaught TypeError: Cannot call method 'setHtml' of null

a.editor.setModeckeditor.js:127
j.add.init.n.on.mckeditor.js:127
a.event.on.mckeditor.js:6
a.event.fireckeditor.js:6
a.editor.fireckeditor.js:7
a.event.fireOnceckeditor.js:6
a.editor.fireOnceckeditor.js:7
a.themes.add.build
...more

comment:8 Changed 21 months ago by inghamc

  • Cc chris.ingham@… added

Adding Cc:

Note: See TracTickets for help on using tickets.
© 2003 – 2012 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy