From 351ef2a6dece8d0d66dc64cfc6184f77f57ea282 Mon Sep 17 00:00:00 2001 From: WilliamKoza Date: Wed, 16 Jan 2019 20:21:40 +0100 Subject: [PATCH] fix(docs-infra): removal of the use of the ChildNode.remove() method that it isn't supported by IE (#28188) fixes #28177 PR Close #28188 --- aio/src/app/layout/doc-viewer/doc-viewer.component.ts | 5 +++-- aio/src/app/shared/toc.service.ts | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/aio/src/app/layout/doc-viewer/doc-viewer.component.ts b/aio/src/app/layout/doc-viewer/doc-viewer.component.ts index a1b5ddabb0..3915a2ad9f 100644 --- a/aio/src/app/layout/doc-viewer/doc-viewer.component.ts +++ b/aio/src/app/layout/doc-viewer/doc-viewer.component.ts @@ -100,9 +100,10 @@ export class DocViewerComponent implements OnDestroy { if (needsToc && !embeddedToc) { // Add an embedded ToC if it's needed and there isn't one in the content already. titleEl!.insertAdjacentHTML('afterend', ''); - } else if (!needsToc && embeddedToc) { + } else if (!needsToc && embeddedToc && embeddedToc.parentNode !== null) { // Remove the embedded Toc if it's there and not needed. - embeddedToc.remove(); + // We cannot use ChildNode.remove() because of IE11 + embeddedToc.parentNode.removeChild(embeddedToc); } return () => { diff --git a/aio/src/app/shared/toc.service.ts b/aio/src/app/shared/toc.service.ts index e5fdd0196a..0c6a53b572 100644 --- a/aio/src/app/shared/toc.service.ts +++ b/aio/src/app/shared/toc.service.ts @@ -68,7 +68,10 @@ export class TocService { } } // now remove the anchor - anchorLink.remove(); + if (anchorLink.parentNode !== null) { + // We cannot use ChildNode.remove() because of IE11 + anchorLink.parentNode.removeChild(anchorLink); + } } // security: the document element which provides this heading content // is always authored by the documentation team and is considered to be safe