Browse Source

Used BalloonPanelView's attachTo object syntax.

Aleksander Nowodzinski 9 years ago
parent
commit
b47ae9cfd0
2 changed files with 12 additions and 7 deletions
  1. 4 3
      packages/ckeditor5-link/src/link.js
  2. 8 4
      packages/ckeditor5-link/tests/link.js

+ 4 - 3
packages/ckeditor5-link/src/link.js

@@ -222,8 +222,6 @@ export default class Link extends Plugin {
 		const viewDocument = this.editor.editing.view;
 		const targetLink = parentLink || getPositionParentLink( viewDocument.selection.getFirstPosition() );
 
-		this.balloonPanelView.limiter = viewDocument.domConverter.getCorrespondingDomElement( viewDocument.selection.editableElement );
-
 		const target = targetLink ?
 				// When selection is inside link element, then attach panel to this element.
 				viewDocument.domConverter.getCorrespondingDomElement( targetLink )
@@ -231,7 +229,10 @@ export default class Link extends Plugin {
 				// Otherwise attach panel to the selection.
 				viewDocument.domConverter.viewRangeToDom( viewDocument.selection.getFirstRange() );
 
-		this.balloonPanelView.attachTo( target );
+		this.balloonPanelView.attachTo( {
+			target,
+			limiter: viewDocument.domConverter.getCorrespondingDomElement( viewDocument.selection.editableElement )
+		} );
 	}
 
 	/**

+ 8 - 4
packages/ckeditor5-link/tests/link.js

@@ -91,8 +91,10 @@ describe( 'Link', () => {
 
 			const linkElement = editorElement.querySelector( 'a' );
 
-			expect( balloonPanelView.limiter ).to.equal( editorElement );
-			expect( attachToSpy.calledWithExactly( linkElement ) ).to.true;
+			sinon.assert.calledWithExactly( attachToSpy, sinon.match( {
+				target: linkElement,
+				limiter: editorElement
+			} ) );
 		} );
 
 		it( 'should open panel attached to the selection, when there is non-collapsed selection', () => {
@@ -106,8 +108,10 @@ describe( 'Link', () => {
 
 			const selectedRange = editorElement.ownerDocument.getSelection().getRangeAt( 0 );
 
-			expect( balloonPanelView.limiter ).to.equal( editorElement );
-			expect( attachToSpy.calledWithExactly( selectedRange ) ).to.true;
+			sinon.assert.calledWithExactly( attachToSpy, sinon.match( {
+				target: selectedRange,
+				limiter: editorElement
+			} ) );
 		} );
 
 		it( 'should select panel input value when panel is opened', () => {