Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make CKEditor 4 works in strict mode #5049

Closed
SuperPat45 opened this issue Jan 26, 2022 · 2 comments · Fixed by #5141
Closed

Make CKEditor 4 works in strict mode #5049

SuperPat45 opened this issue Jan 26, 2022 · 2 comments · Fixed by #5141
Assignees
Labels
core The issue is caused by the editor core code. regression This issue is a regression. status:confirmed An issue confirmed by the development team. type:bug A bug.
Milestone

Comments

@SuperPat45
Copy link
Contributor

SuperPat45 commented Jan 26, 2022

Type of report

Bug

Provide detailed reproduction steps (if any)

  1. Simply add "use strict"; at the beginning of the compiled ckeditor.js

Expected result

It should work

Actual result

An exception is thrown:

TypeError: this is undefined
getClientRects http://localhost:8080/ckeditor.js:12586
<anonymous> http://localhost:8080/ckeditor.js:12805
<anonymous> http://localhost:8080/ckeditor.js:12934
<anonymous> http://localhost:8080/ckeditor.js:64500

Other details

The error is in the getClientRects function of the range.js source, where this is undefined in strict mode:

getClientRects: ( function() {
	if ( this.document.getSelection !== undefined ) {
		return function( isAbsolute ) {
			// We need to create native range so we can call native getClientRects.
			var range = this.root.getDocument().$.createRange(),
				rectList;

			range.setStart( this.startContainer.$, this.startOffset );
			range.setEnd( this.endContainer.$, this.endOffset );

			rectList = range.getClientRects();

			rectList = fixWidgetsRects( rectList, this );

			if ( !rectList.length ) {
				rectList = fixEmptyRectList( rectList, range, this );
			}

			return CKEDITOR.tools.array.map( rectList, function( item ) {
				return convertRect( item, isAbsolute, this );
			}, this );
		};
	} else {
		return function( isAbsolute ) {
			return [ convertRect( getRect( this.createBookmark() ), isAbsolute, this ) ];
		};
	}

There is probably other bugs to fix in strict mode

  • Browser: Firefox 96
  • OS: Windows 10
  • CKEditor version: 4.17.1
  • Installed CKEditor plugins: Full preset
@SuperPat45 SuperPat45 added the type:bug A bug. label Jan 26, 2022
@Comandeer
Copy link
Member

I can confirm the issue.

@Comandeer Comandeer added core The issue is caused by the editor core code. size:? status:confirmed An issue confirmed by the development team. labels Jan 26, 2022
@jacekbogdanski jacekbogdanski added regression This issue is a regression. size:XS and removed size:? labels Feb 1, 2022
@sculpt0r sculpt0r self-assigned this Mar 29, 2022
@CKEditorBot
Copy link
Collaborator

Closed in #5141

@CKEditorBot CKEditorBot added this to the 4.18.1 milestone Apr 22, 2022
@jacekbogdanski jacekbogdanski modified the milestones: 4.18.1, 4.19.0 May 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core The issue is caused by the editor core code. regression This issue is a regression. status:confirmed An issue confirmed by the development team. type:bug A bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants