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

Some ranges throw error when calling `deleteContents(true)` #3041

Open engineering-this opened 5 years ago

engineering-this commented 5 years ago

Type of report

Bug

Provide detailed reproduction steps (if any)

  1. Open https://codepen.io/jacekbogdanski/pen/XWEygOX
  2. Open browser console.
  3. Press button below editor.

Expected result

Editor content is removed.

Actual result

Error thrown

pen.js:13 TypeError: Cannot read property 'insertBefore' of null
    at CKEDITOR.dom.element.insertAfter (ckeditor.js:76)
    at h (ckeditor.js:149)
    at d (ckeditor.js:151)
    at CKEDITOR.dom.range.deleteContents (ckeditor.js:155)
    at CKEDITOR.dom.element.<anonymous> (pen.js:11)
    at CKEDITOR.dom.element.p (ckeditor.js:10)
    at CKEDITOR.dom.element.fire (ckeditor.js:12)
    at HTMLButtonElement.<anonymous> (ckeditor.js:68)

Other details

This is reproducible, when below criteria are met:

engineering-this commented 5 years ago

Extracted from https://github.com/ckeditor/ckeditor-dev/issues/2517#issuecomment-481192985