@@ -767,6 +767,29 @@ describe('FlexibleConnectedPositionStrategy', () => {
767767
768768 } ) ;
769769
770+ it ( 'should position the panel correctly when the origin is an SVG element' , ( ) => {
771+ document . body . removeChild ( originElement ) ;
772+ originElement = createBlockElement ( 'svg' , 'http://www.w3.org/2000/svg' ) ;
773+ document . body . appendChild ( originElement ) ;
774+
775+ const originRect = originElement . getBoundingClientRect ( ) ;
776+
777+ positionStrategy
778+ . setOrigin ( originElement )
779+ . withPositions ( [ {
780+ originX : 'start' ,
781+ originY : 'bottom' ,
782+ overlayX : 'start' ,
783+ overlayY : 'top'
784+ } ] ) ;
785+
786+ attachOverlay ( { positionStrategy} ) ;
787+
788+ const overlayRect = overlayRef . overlayElement . getBoundingClientRect ( ) ;
789+ expect ( Math . floor ( overlayRect . top ) ) . toBe ( Math . floor ( originRect . bottom ) ) ;
790+ expect ( Math . floor ( overlayRect . left ) ) . toBe ( Math . floor ( originRect . left ) ) ;
791+ } ) ;
792+
770793 it ( 'should account for the `offsetX` pushing the overlay out of the screen' , ( ) => {
771794 // Position the element so it would have enough space to fit.
772795 originElement . style . top = '200px' ;
@@ -2592,8 +2615,15 @@ function createPositionedBlockElement() {
25922615}
25932616
25942617/** Creates a block element with a default size. */
2595- function createBlockElement ( ) {
2596- const element = document . createElement ( 'div' ) ;
2618+ function createBlockElement ( tagName = 'div' , namespace ?: string ) {
2619+ let element ;
2620+
2621+ if ( namespace ) {
2622+ element = document . createElementNS ( namespace , tagName ) as HTMLElement ;
2623+ } else {
2624+ element = document . createElement ( tagName ) ;
2625+ }
2626+
25972627 element . style . width = `${ DEFAULT_WIDTH } px` ;
25982628 element . style . height = `${ DEFAULT_HEIGHT } px` ;
25992629 element . style . backgroundColor = 'rebeccapurple' ;
0 commit comments