* Get the owning context for a binding or its key * @param keyOrBinding - Binding object or key
(
keyOrBinding: BindingAddress | Readonly<Binding<unknown>>,
)
| 480 | * @param keyOrBinding - Binding object or key |
| 481 | */ |
| 482 | getOwnerContext( |
| 483 | keyOrBinding: BindingAddress | Readonly<Binding<unknown>>, |
| 484 | ): Context | undefined { |
| 485 | let key: BindingAddress; |
| 486 | if (keyOrBinding instanceof Binding) { |
| 487 | key = keyOrBinding.key; |
| 488 | } else { |
| 489 | key = keyOrBinding as BindingAddress; |
| 490 | } |
| 491 | if (this.contains(key)) { |
| 492 | if (keyOrBinding instanceof Binding) { |
| 493 | // Check if the contained binding is the same |
| 494 | if (this.registry.get(key.toString()) === keyOrBinding) { |
| 495 | return this; |
| 496 | } |
| 497 | return undefined; |
| 498 | } |
| 499 | return this; |
| 500 | } |
| 501 | if (this._parent) { |
| 502 | return this._parent.getOwnerContext(key); |
| 503 | } |
| 504 | return undefined; |
| 505 | } |
| 506 | |
| 507 | /** |
| 508 | * Get the context matching the scope |
no test coverage detected