This repository has been archived by the owner on Jun 26, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #207 from ckeditor/i/6002
Tests: Fixed tests leaking editor instances and DOM elements. See ckeditor/ckeditor5#6002.
- Loading branch information
Showing
3 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved. | ||
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license | ||
*/ | ||
|
||
/* globals document */ | ||
|
||
import Locale from '@ckeditor/ckeditor5-utils/src/locale'; | ||
import EditorUIView from '@ckeditor/ckeditor5-ui/src/editorui/editoruiview'; | ||
import { removeEditorBodyOrphans } from '../_utils/cleanup'; | ||
|
||
describe( 'cleanup util', () => { | ||
describe( 'removeEditorBodyOrphans()', () => { | ||
const locale = new Locale(); | ||
const uiViews = [ new EditorUIView( locale ), new EditorUIView( locale ) ]; | ||
|
||
for ( const view of uiViews ) { | ||
view.render(); | ||
} | ||
|
||
expect( document.querySelectorAll( '.ck-body' ) ).to.have.length( 2 ); | ||
|
||
removeEditorBodyOrphans(); | ||
|
||
expect( document.querySelectorAll( '.ck-body' ) ).to.have.length( 0 ); | ||
} ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/** | ||
* @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved. | ||
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license | ||
*/ | ||
|
||
/* global document */ | ||
|
||
/** | ||
* Removes all the `.ck-body` elements available in the DOM. | ||
* | ||
* It is commonly used to cleanup after editors that test editor crashes. | ||
* | ||
* See https://github.com/ckeditor/ckeditor5/issues/6018 for more details. | ||
*/ | ||
export function removeEditorBodyOrphans() { | ||
for ( const bodyOrphan of document.querySelectorAll( '.ck-body' ) ) { | ||
bodyOrphan.remove(); | ||
} | ||
} |