@@ -45,9 +45,6 @@ export type FlexibleConnectedPositionStrategyOrigin =
4545/** Equivalent of `DOMRect` without some of the properties we don't care about. */
4646type Dimensions = Omit < DOMRect , 'x' | 'y' | 'toJSON' > ;
4747
48- /** Possible point to attach a popover to. */
49- export type PopoverInsertionPoint = Element | { type : 'parent' ; element : Element } | null ;
50-
5148/**
5249 * Creates a flexible position strategy.
5350 * @param injector Injector used to resolve dependnecies for the position strategy.
@@ -70,7 +67,7 @@ export function createFlexibleConnectedPositionStrategy(
7067export type FlexibleOverlayPopoverLocation =
7168 | 'global'
7269 | 'inline'
73- | { type : 'parent' ; element : FlexibleConnectedPositionStrategyOrigin } ;
70+ | { type : 'parent' ; element : Element } ;
7471
7572/**
7673 * A strategy for positioning overlays. Using this strategy, an overlay is given an
@@ -537,36 +534,32 @@ export class FlexibleConnectedPositionStrategy implements PositionStrategy {
537534 }
538535
539536 /** @docs -private */
540- getPopoverInsertionPoint ( ) : PopoverInsertionPoint {
537+ getPopoverInsertionPoint ( ) : Element | null | { type : 'parent' ; element : Element } {
541538 if ( this . _popoverLocation === 'global' ) {
542539 return null ;
543540 }
544541
545- const origin =
546- this . _popoverLocation === 'inline'
547- ? this . _origin
548- : (
549- this . _popoverLocation as {
550- type : 'parent' ;
551- element : FlexibleConnectedPositionStrategyOrigin ;
552- }
553- ) . element ;
554- let element : Element | null = null ;
542+ let hostElement : Element | null = null ;
555543
556- if ( origin instanceof ElementRef ) {
557- element = origin . nativeElement ;
558- } else if ( origin instanceof Element ) {
559- element = origin ;
544+ if ( this . _popoverLocation === 'inline' ) {
545+ if ( this . _origin instanceof ElementRef ) {
546+ hostElement = this . _origin . nativeElement ;
547+ } else if ( this . _origin instanceof Element ) {
548+ hostElement = this . _origin ;
549+ }
550+ } else {
551+ // this._popoverLocation is {type: 'parent', element: Element}
552+ hostElement = this . _popoverLocation . element ;
560553 }
561554
562555 // If the location is 'inline', we're inserting as a sibling.
563556 if ( this . _popoverLocation === 'inline' ) {
564- return element ;
557+ return hostElement ;
565558 }
566559
567560 // Otherwise we're inserting as a child.
568- if ( element ) {
569- return { type : 'parent' , element : element } ;
561+ if ( hostElement ) {
562+ return { type : 'parent' , element : hostElement } ;
570563 }
571564
572565 return null ;
0 commit comments