/** * A `ComponentPortal` is a portal that instantiates some Component upon attachment. */ export class ComponentPortal { _attachedHost; /** The type of the component that will be instantiated for attachment. */ component; /** * [Optional] Where the attached component should live in Angular's *logical* component tree. * This is different from where the component *renders*, which is determined by the PortalHost. * The origin necessary when the host is outside of the Angular application context. */ viewContainerRef; /** Injector used for the instantiation of the component. */ injector; constructor(component, injector) { this.component = component; this.injector = injector; } /** Attach this portal to a host. */ attach(host, newestOnTop) { this._attachedHost = host; return host.attach(this, newestOnTop); } /** Detach this portal from its host */ detach() { const host = this._attachedHost; if (host) { this._attachedHost = undefined; return host.detach(); } } /** Whether this portal is attached to a host. */ get isAttached() { return this._attachedHost != null; } /** * Sets the PortalHost reference without performing `attach()`. This is used directly by * the PortalHost when it is performing an `attach()` or `detach()`. */ setAttachedHost(host) { this._attachedHost = host; } } /** * Partial implementation of PortalHost that only deals with attaching a * ComponentPortal */ export class BasePortalHost { /** The portal currently attached to the host. */ _attachedPortal; /** A function that will permanently dispose this host. */ _disposeFn; attach(portal, newestOnTop) { this._attachedPortal = portal; return this.attachComponentPortal(portal, newestOnTop); } detach() { if (this._attachedPortal) { this._attachedPortal.setAttachedHost(); } this._attachedPortal = undefined; if (this._disposeFn) { this._disposeFn(); this._disposeFn = undefined; } } setDisposeFn(fn) { this._disposeFn = fn; } } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicG9ydGFsLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2xpYi9wb3J0YWwvcG9ydGFsLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQVdBOztHQUVHO0FBQ0gsTUFBTSxPQUFPLGVBQWU7SUFDbEIsYUFBYSxDQUFrQjtJQUN2QywwRUFBMEU7SUFDMUUsU0FBUyxDQUFtQjtJQUU1Qjs7OztPQUlHO0lBQ0gsZ0JBQWdCLENBQW9CO0lBRXBDLDREQUE0RDtJQUM1RCxRQUFRL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