Sfoglia il codice sorgente

Moved init of the balloon view to the class constructor.

Oskar Wróbel 8 anni fa
parent
commit
8169b5f16a

+ 9 - 6
packages/ckeditor5-ui/src/contextualballoon.js

@@ -8,6 +8,7 @@
  */
 
 import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
+import BalloonPanelView from './panel/balloon/balloonpanelview';
 
 /**
  * Common contextual balloon of the Editor.
@@ -23,6 +24,14 @@ export default class ContextualBalloon {
 	 * @constructor
 	 */
 	constructor() {
+		/**
+		 * Balloon panel view.
+		 *
+		 * @readonly
+		 * @member {module:ui/panel/balloon/balloonpanelview~BalloonPanelView} #view
+		 */
+		this.view = new BalloonPanelView();
+
 		/**
 		 * Stack of panels injected to the balloon. Last one in the stack is displayed
 		 * as content of {@link module:ui/contextualballoon~ContextualBalloon#view}.
@@ -31,12 +40,6 @@ export default class ContextualBalloon {
 		 * @member {Map} #_stack
 		 */
 		this._stack = new Map();
-
-		/**
-		 * Balloon panel view.
-		 *
-		 * @member {module:ui:view~View} #view
-		 */
 	}
 
 	/**

+ 6 - 1
packages/ckeditor5-ui/tests/contextualballoon.js

@@ -14,7 +14,6 @@ describe( 'ContextualBalloon', () => {
 
 	beforeEach( () => {
 		balloon = new ContextualBalloon();
-		balloon.view = new BalloonPanelView();
 
 		viewA = new ViewA();
 		viewB = new ViewB();
@@ -27,6 +26,12 @@ describe( 'ContextualBalloon', () => {
 		balloon.view.attachTo.restore();
 	} );
 
+	describe( 'constructor()', () => {
+		it( 'should create a class instance with properties', () => {
+			expect( balloon.view ).to.instanceof( BalloonPanelView );
+		} );
+	} );
+
 	describe( 'isPanelInStack()', () => {
 		it( 'should return true when panel of given view is in stack', () => {
 			balloon.add( {