Explorar el Código

Tests: Added test to verify BalloonPanelView#pin method when the limiter is not an HTML element or DOM Range.

Aleksander Nowodzinski hace 8 años
padre
commit
d56b40827d

+ 1 - 1
packages/ckeditor5-ui/src/panel/balloon/balloonpanelview.js

@@ -254,7 +254,7 @@ export default class BalloonPanelView extends View {
 		this.attachTo( options );
 
 		const targetElement = getDomElement( options.target );
-		const limiterElement = getDomElement( options.limiter ) || defaultLimiterElement;
+		const limiterElement = options.limiter ? getDomElement( options.limiter ) : defaultLimiterElement;
 
 		// Then we need to listen on scroll event of eny element in the document.
 		this.listenTo( global.document, 'scroll', ( evt, domEvt ) => {

+ 11 - 0
packages/ckeditor5-ui/tests/panel/balloon/balloonpanelview.js

@@ -624,6 +624,17 @@ describe( 'BalloonPanelView', () => {
 				notRelatedElement.dispatchEvent( new Event( 'scroll' ) );
 				sinon.assert.calledTwice( attachToSpy );
 			} );
+
+			// https://github.com/ckeditor/ckeditor5-ui/issues/260
+			it( 'should react to #scroll from anywhere when the limiter is not an HTMLElement or Range', () => {
+				const rect = {};
+
+				view.pin( { target, limiter: rect } );
+				sinon.assert.calledOnce( attachToSpy );
+
+				notRelatedElement.dispatchEvent( new Event( 'scroll' ) );
+				sinon.assert.calledTwice( attachToSpy );
+			} );
 		} );
 
 		describe( 'unpin()', () => {