@@ -767,6 +767,29 @@ describe('FlexibleConnectedPositionStrategy', () => {
767
767
768
768
} ) ;
769
769
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
+
770
793
it ( 'should account for the `offsetX` pushing the overlay out of the screen' , ( ) => {
771
794
// Position the element so it would have enough space to fit.
772
795
originElement . style . top = '200px' ;
@@ -2592,8 +2615,15 @@ function createPositionedBlockElement() {
2592
2615
}
2593
2616
2594
2617
/** 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
+
2597
2627
element . style . width = `${ DEFAULT_WIDTH } px` ;
2598
2628
element . style . height = `${ DEFAULT_HEIGHT } px` ;
2599
2629
element . style . backgroundColor = 'rebeccapurple' ;
0 commit comments