From 79289b8368a26cf9aaff2e05bc48e8add628f03b Mon Sep 17 00:00:00 2001 From: Shawn Yoon Date: Sun, 12 Jul 2020 13:43:15 -0400 Subject: [PATCH 1/3] added a null guard --- src/cdk/a11y/aria-describer/aria-describer.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cdk/a11y/aria-describer/aria-describer.ts b/src/cdk/a11y/aria-describer/aria-describer.ts index 9af03d02a73b..62407a90d416 100644 --- a/src/cdk/a11y/aria-describer/aria-describer.ts +++ b/src/cdk/a11y/aria-describer/aria-describer.ts @@ -159,7 +159,7 @@ export class AriaDescriber implements OnDestroy { // already a container on the page, but we don't have a reference to it. Clear the // old container so we don't get duplicates. Doing this, instead of emptying the previous // container, should be slightly faster. - if (preExistingContainer) { + if (preExistingContainer && preExistingContainer.parentNode) { preExistingContainer.parentNode!.removeChild(preExistingContainer); } From 26b16cfce7b9ff141d564f5b49f564333200ae57 Mon Sep 17 00:00:00 2001 From: Shawn Yoon Date: Sun, 12 Jul 2020 15:06:09 -0400 Subject: [PATCH 2/3] remove ! --- src/cdk/a11y/aria-describer/aria-describer.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cdk/a11y/aria-describer/aria-describer.ts b/src/cdk/a11y/aria-describer/aria-describer.ts index 62407a90d416..c24601d7b2f6 100644 --- a/src/cdk/a11y/aria-describer/aria-describer.ts +++ b/src/cdk/a11y/aria-describer/aria-describer.ts @@ -160,7 +160,7 @@ export class AriaDescriber implements OnDestroy { // old container so we don't get duplicates. Doing this, instead of emptying the previous // container, should be slightly faster. if (preExistingContainer && preExistingContainer.parentNode) { - preExistingContainer.parentNode!.removeChild(preExistingContainer); + preExistingContainer.parentNode.removeChild(preExistingContainer); } messagesContainer = this._document.createElement('div'); From cd3837493d71bf1b9b854cfae55603fca882ea5f Mon Sep 17 00:00:00 2001 From: Shawn Yoon Date: Sun, 12 Jul 2020 13:43:15 -0400 Subject: [PATCH 3/3] fix (a11y): add parent node check when removing existing aria describe --- src/cdk/a11y/aria-describer/aria-describer.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cdk/a11y/aria-describer/aria-describer.ts b/src/cdk/a11y/aria-describer/aria-describer.ts index 9af03d02a73b..c24601d7b2f6 100644 --- a/src/cdk/a11y/aria-describer/aria-describer.ts +++ b/src/cdk/a11y/aria-describer/aria-describer.ts @@ -159,8 +159,8 @@ export class AriaDescriber implements OnDestroy { // already a container on the page, but we don't have a reference to it. Clear the // old container so we don't get duplicates. Doing this, instead of emptying the previous // container, should be slightly faster. - if (preExistingContainer) { - preExistingContainer.parentNode!.removeChild(preExistingContainer); + if (preExistingContainer && preExistingContainer.parentNode) { + preExistingContainer.parentNode.removeChild(preExistingContainer); } messagesContainer = this._document.createElement('div');